mirror of https://github.com/layui/layui
修复 treeTable 开启了 sort 之后出现的一些异常问题
parent
a648b1428d
commit
29547007f5
|
@ -142,6 +142,10 @@ layui.define(['table'], function (exports) {
|
||||||
retData[dataName] = that.flatToTree(retData[dataName]);
|
retData[dataName] = that.flatToTree(retData[dataName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parseDataThat.autoSort && parseDataThat.initSort && parseDataThat.initSort.type) {
|
||||||
|
layui.sort(retData[dataName], parseDataThat.initSort.field, parseDataThat.initSort.type === 'desc', true)
|
||||||
|
}
|
||||||
|
|
||||||
that.initData(retData[dataName]);
|
that.initData(retData[dataName]);
|
||||||
|
|
||||||
return retData;
|
return retData;
|
||||||
|
@ -155,7 +159,7 @@ layui.define(['table'], function (exports) {
|
||||||
options.data = that.flatToTree(options.data);
|
options.data = that.flatToTree(options.data);
|
||||||
}
|
}
|
||||||
if (options.initSort && options.initSort.type) {
|
if (options.initSort && options.initSort.type) {
|
||||||
options.data = layui.sort(options.data, options.initSort.field, options.initSort.type === 'desc')
|
layui.sort(options.data, options.initSort.field, options.initSort.type === 'desc', true)
|
||||||
}
|
}
|
||||||
that.initData(options.data);
|
that.initData(options.data);
|
||||||
}
|
}
|
||||||
|
@ -401,7 +405,7 @@ layui.define(['table'], function (exports) {
|
||||||
that.initData(item1[childrenKey] || [], dataIndex);
|
that.initData(item1[childrenKey] || [], dataIndex);
|
||||||
});
|
});
|
||||||
|
|
||||||
parentIndex || updateCache(tableId, childrenKey);
|
updateCache(tableId, childrenKey, data);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -561,13 +565,13 @@ layui.define(['table'], function (exports) {
|
||||||
trExpanded = trData[LAY_HAS_EXPANDED] = true;
|
trExpanded = trData[LAY_HAS_EXPANDED] = true;
|
||||||
if (childNodes.length) {
|
if (childNodes.length) {
|
||||||
// 判断是否需要排序
|
// 判断是否需要排序
|
||||||
if (options.initSort && !options.url) {
|
if (options.initSort && (!options.url || options.autoSort)) {
|
||||||
var initSort = options.initSort;
|
var initSort = options.initSort;
|
||||||
if (initSort.type) {
|
if (initSort.type) {
|
||||||
childNodes = trData[customName.children] = layui.sort(childNodes, initSort.field, initSort.type === 'desc');
|
layui.sort(childNodes, initSort.field, initSort.type === 'desc', true);
|
||||||
} else {
|
} else {
|
||||||
// 恢复默认
|
// 恢复默认
|
||||||
childNodes = trData[customName.children] = layui.sort(childNodes, table.config.indexName);
|
layui.sort(childNodes, table.config.indexName, null, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
treeTableThat.initData(trData[customName.children], trData[LAY_DATA_INDEX]);
|
treeTableThat.initData(trData[customName.children], trData[LAY_DATA_INDEX]);
|
||||||
|
@ -1007,9 +1011,9 @@ layui.define(['table'], function (exports) {
|
||||||
|
|
||||||
if (!options.url) {
|
if (!options.url) {
|
||||||
if (initSort.type) {
|
if (initSort.type) {
|
||||||
options.data = layui.sort(options.data, initSort.field, initSort.type === 'desc');
|
layui.sort(options.data, initSort.field, initSort.type === 'desc', true);
|
||||||
} else {
|
} else {
|
||||||
options.data = layui.sort(options.data, table.config.indexName);
|
layui.sort(options.data, table.config.indexName, null, true);
|
||||||
}
|
}
|
||||||
that.initData(options.data);
|
that.initData(options.data);
|
||||||
treeTable.reloadData(id);
|
treeTable.reloadData(id);
|
||||||
|
|
Loading…
Reference in New Issue