修复 treeTable data 模式下排序之后出现节点结构错乱的问题

pull/1358/head
sunxiaobin89 2023-08-29 02:38:09 +08:00
parent 917159cd1d
commit c9d67979f5
1 changed files with 7 additions and 3 deletions

View File

@ -190,6 +190,9 @@ layui.define(['table'], function (exports) {
indeterminate: !checkStatus.isAll && checkStatus.data.length indeterminate: !checkStatus.isAll && checkStatus.data.length
}) })
} }
if (!isRenderData && thatOptionsTemp.autoSort && thatOptionsTemp.initSort && thatOptionsTemp.initSort.type) {
treeTable.sort(id);
}
that.renderTreeTable(tableView); that.renderTreeTable(tableView);
@ -909,7 +912,7 @@ layui.define(['table'], function (exports) {
d[idKey] !== undefined && (that.status.expand[d[idKey]] = true); d[idKey] !== undefined && (that.status.expand[d[idKey]] = true);
} }
}); });
if (options.initSort && options.initSort.type && (!options.url || options.autoSort)) { if (options.initSort && options.initSort.type && options.autoSort) {
return treeTable.sort(id); return treeTable.sort(id);
} }
var trAll = table.getTrHtml(id, tableDataFlat); var trAll = table.getTrHtml(id, tableDataFlat);
@ -1126,7 +1129,8 @@ layui.define(['table'], function (exports) {
Class.prototype.getTableData = function () { Class.prototype.getTableData = function () {
var that = this; var that = this;
var options = that.getOptions(); var options = that.getOptions();
return options.url ? table.cache[options.id] : options.data; // return options.url ? table.cache[options.id] : options.data;
return table.cache[options.id];
} }
treeTable.updateStatus = function (id, statusObj, data) { treeTable.updateStatus = function (id, statusObj, data) {
@ -1147,7 +1151,7 @@ layui.define(['table'], function (exports) {
if(!that) return; if(!that) return;
var options = that.getOptions(); var options = that.getOptions();
if (!options.url || options.autoSort) { if (options.autoSort) {
that.initData(); that.initData();
treeTable.renderData(id); treeTable.renderData(id);
} }