You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
3.9 KiB
89 lines
3.9 KiB
3 years ago
|
fineUi的Tree我们一般这么配
|
||
|
|
||
|
var items = this._formatTreeItems(BI.Tree.transformToTreeFormat(this.store.getTreeJsonWithNode()), 0);
|
||
|
|
||
|
t = {
|
||
|
type: "bi.custom_tree",
|
||
|
$testId: "decision-normal-table-tree-scroll",
|
||
|
$value: e.authType + "-" + e.entityType,
|
||
|
ref: function (e) {
|
||
|
n.tree = e
|
||
|
},
|
||
|
expander: {
|
||
|
type: "dec.base.tree_expander",
|
||
|
isDefaultInit: !1,
|
||
|
el: {},
|
||
|
popup: {
|
||
|
type: "bi.custom_tree"
|
||
|
}
|
||
|
},
|
||
|
items: t,
|
||
|
itemsCreator: function (t, i) {
|
||
|
e.itemsCreator(t, function (e) {
|
||
|
e = n.store.cacheTreeData(e, t);
|
||
|
var a = n._formatTreeItems(e, t.node ? t.node.layer : 0)
|
||
|
console.log("a:" + a)
|
||
|
i(a)
|
||
|
})
|
||
|
},
|
||
|
el: {
|
||
|
type: e.lazy ? "dec.component.lazy_loader" : "dec.component.gradually_loader",
|
||
|
next: !1,
|
||
|
getScrollParent: function () {
|
||
|
return n.tree.element
|
||
|
},
|
||
|
el: {
|
||
|
type: "bi.button_tree",
|
||
|
chooseType: 1,
|
||
|
layouts: [{
|
||
|
type: "bi.vertical"
|
||
|
}]
|
||
|
}
|
||
|
},
|
||
|
listeners: [{
|
||
|
eventName: BI.Controller.EVENT_CHANGE,
|
||
|
action: function (e, t, i) {
|
||
|
n.fireEvent(BI.Controller.EVENT_CHANGE, arguments)
|
||
|
}
|
||
|
}]
|
||
|
};
|
||
|
|
||
|
|
||
|
itemsCreator是异步数据回调接口,
|
||
|
itemsCreator: function (t, i) {
|
||
|
e.itemsCreator(t, function (e) {
|
||
|
e = n.store.cacheTreeData(e, t);
|
||
|
var a = n._formatTreeItems(e, t.node ? t.node.layer : 0)
|
||
|
console.log("a:" + a)
|
||
|
i(a)
|
||
|
})
|
||
|
},
|
||
|
这里是调用options中的itemsCreator来获取数据,回调函数获取到数据后,调用i(a)来渲染数据。
|
||
|
a的数据格式一般为:[
|
||
|
{
|
||
|
|
||
|
|
||
|
children: Array(5)
|
||
|
id: "-1_0"
|
||
|
isParent: true
|
||
|
layer: 0 //控制层级
|
||
|
open: true //是否打开
|
||
|
order: 0
|
||
|
pId: null //父id
|
||
|
selected: true //是否选中
|
||
|
text: "中国铁建"
|
||
|
}
|
||
|
]
|
||
|
options的itemsCreator中一般这么写:
|
||
|
if(e.node){
|
||
|
i.store.getSubItemsByPId(e.node.id, e.node.layer + 1, function (e) {
|
||
|
console.log(e);
|
||
|
t(e)
|
||
|
})
|
||
|
}
|
||
|
else{
|
||
|
var rootnodes = i.store.getRootNodes();
|
||
|
console.log("rootnodes:"+rootnodes)
|
||
|
t(rootnodes)
|
||
|
}
|