mirror of https://github.com/layui/layui
修改 treeTable 的 `data.rootPId` 为 `data.rootPid`
parent
bafce57956
commit
f3527427d0
|
@ -232,7 +232,7 @@ layui.define(['table'], function (exports) {
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
isSimpleData: false, // 是否简单数据模式
|
isSimpleData: false, // 是否简单数据模式
|
||||||
rootPId: null // 根节点的父 ID 值
|
rootPid: null // 根节点的父 ID 值
|
||||||
},
|
},
|
||||||
async: {
|
async: {
|
||||||
enable: false, // 是否开启异步加载模式,只有开启的时候其他参数才起作用
|
enable: false, // 是否开启异步加载模式,只有开启的时候其他参数才起作用
|
||||||
|
@ -259,7 +259,7 @@ layui.define(['table'], function (exports) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function flatToTree(flatArr, idKey, pIdKey, childrenKey, rootPId) {
|
function flatToTree(flatArr, idKey, pIdKey, childrenKey, rootPid) {
|
||||||
idKey = idKey || 'id';
|
idKey = idKey || 'id';
|
||||||
pIdKey = pIdKey || 'parentId';
|
pIdKey = pIdKey || 'parentId';
|
||||||
childrenKey = childrenKey || 'children';
|
childrenKey = childrenKey || 'children';
|
||||||
|
@ -278,7 +278,7 @@ layui.define(['table'], function (exports) {
|
||||||
})
|
})
|
||||||
// 返回顶层节点
|
// 返回顶层节点
|
||||||
return Object.values(nodes).filter(function (item) {
|
return Object.values(nodes).filter(function (item) {
|
||||||
return rootPId ? item[pIdKey] === rootPId : !item[pIdKey];
|
return rootPid ? item[pIdKey] === rootPid : !item[pIdKey];
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ layui.define(['table'], function (exports) {
|
||||||
|
|
||||||
tableData = tableData || table.cache[tableId];
|
tableData = tableData || table.cache[tableId];
|
||||||
|
|
||||||
return flatToTree(tableData, customName.id, customName.pid, customName.children, treeOptions.data.rootPId)
|
return flatToTree(tableData, customName.id, customName.pid, customName.children, treeOptions.data.rootPid)
|
||||||
}
|
}
|
||||||
|
|
||||||
Class.prototype.treeToFlat = function (tableData, parentId, parentIndex) {
|
Class.prototype.treeToFlat = function (tableData, parentId, parentIndex) {
|
||||||
|
|
Loading…
Reference in New Issue