mirror of https://github.com/layui/layui
修复 treeTable `reload` 和 `reloadData` 传参中带了 parseData 和 done 回调的时候渲染异常问题
parent
ab16f47dd1
commit
221009ee51
|
@ -111,31 +111,18 @@ layui.define(['table'], function (exports) {
|
|||
})
|
||||
}
|
||||
|
||||
Class.prototype.init = function () {
|
||||
var that = this;
|
||||
var options = that.config;
|
||||
|
||||
// 先初始一个空的表格以便拿到对应的表格实例信息
|
||||
var tableIns = table.render($.extend({}, options, {
|
||||
data: [],
|
||||
url: '',
|
||||
done: null
|
||||
}))
|
||||
var id = tableIns.config.id;
|
||||
thisTreeTable.that[id] = that; // 记录当前实例对象
|
||||
that.tableIns = tableIns;
|
||||
|
||||
var treeOptions = options.tree;
|
||||
var customName = treeOptions.customName;
|
||||
var isParentKey = customName.isParent;
|
||||
var childrenKey = customName.children;
|
||||
|
||||
var updateOptions = function (id, options, reload) {
|
||||
var that = getThisTable(id);
|
||||
var thatOptionsTemp = $.extend(true, {} , that.getOptions(), options);
|
||||
var treeOptions = thatOptionsTemp.tree;
|
||||
var childrenKey = treeOptions.customName.children;
|
||||
// 处理属性
|
||||
var parseData = options.parseData;
|
||||
var done = options.done;
|
||||
|
||||
if (options.url) {
|
||||
if (thatOptionsTemp.url) {
|
||||
// 异步加载的时候需要处理parseData进行转换
|
||||
if (!reload || (reload && parseData && !parseData.mod)) {
|
||||
options.parseData = function () {
|
||||
var parseDataThat = this;
|
||||
var args = arguments;
|
||||
|
@ -153,6 +140,8 @@ layui.define(['table'], function (exports) {
|
|||
|
||||
return retData;
|
||||
}
|
||||
options.parseData.mod = true
|
||||
}
|
||||
} else {
|
||||
options.data = options.data || [];
|
||||
// 处理 isSimpleData
|
||||
|
@ -165,6 +154,7 @@ layui.define(['table'], function (exports) {
|
|||
that.initData(options.data);
|
||||
}
|
||||
|
||||
if (!reload || (reload && done && !done.mod)) {
|
||||
options.done = function () {
|
||||
var args = arguments;
|
||||
var doneThat = this;
|
||||
|
@ -191,6 +181,30 @@ layui.define(['table'], function (exports) {
|
|||
return done.apply(doneThat, args);
|
||||
}
|
||||
}
|
||||
options.done.mod = true;
|
||||
}
|
||||
}
|
||||
|
||||
Class.prototype.init = function () {
|
||||
var that = this;
|
||||
var options = that.config;
|
||||
|
||||
// 先初始一个空的表格以便拿到对应的表格实例信息
|
||||
var tableIns = table.render($.extend({}, options, {
|
||||
data: [],
|
||||
url: '',
|
||||
done: null
|
||||
}))
|
||||
var id = tableIns.config.id;
|
||||
thisTreeTable.that[id] = that; // 记录当前实例对象
|
||||
that.tableIns = tableIns;
|
||||
|
||||
// var treeOptions = options.tree;
|
||||
// var customName = treeOptions.customName;
|
||||
// var isParentKey = customName.isParent;
|
||||
// var childrenKey = customName.children;
|
||||
|
||||
updateOptions(id, options);
|
||||
}
|
||||
|
||||
// 初始默认配置
|
||||
|
@ -819,6 +833,9 @@ layui.define(['table'], function (exports) {
|
|||
if (layui.type(item) === 'array') delete that.config[key];
|
||||
});
|
||||
|
||||
// 根据需要处理options中的一些参数
|
||||
updateOptions(that.config.id, options, true);
|
||||
|
||||
// 对参数进行深度或浅扩展
|
||||
that.config = $.extend(deep, {}, that.config, options);
|
||||
|
||||
|
|
Loading…
Reference in New Issue