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.

77 lines
1.7 KiB

var mockData = [
{
id: "无锡",
text: "无锡",
isParent: true,
layer: 0
}, {
id: "锡山区",
text: "锡山区",
pId: "无锡",
isParent: true,
layer: 1
}, {
id: "安镇街道",
text: "安镇街道",
pId: "锡山区",
layer: 2
}, {
id: "滨湖区",
text: "滨湖区",
pId: "无锡",
layer: 1
}, {
id: "南京",
text: "南京",
isParent: true,
layer: 0
}, {
id: "建邺区",
text: "建邺区",
pId: "南京",
layer: 1
}
];
var Tree = BI.inherit(BI.Widget, {
render: function () {
return {
type: "bi.custom_tree",
expander: {
type: "bi.select_tree_expander",
isDefaultInit: false,
el: {},
popup: {
type: "bi.custom_tree",
},
},
el: {
type: "bi.button_tree",
chooseType: 0,
layouts: [
{
type: "bi.vertical",
},
],
},
items: this._formatItems(mockData)
}
},
_formatItems: function (items) {
return BI.map(items, function (index, item) {
return BI.extend({
type: item.isParent ? "bi.example.select_custom_tree.node" : "bi.example.select_custom_tree.item"
}, item)
})
}
});
BI.shortcut("bi.example.select_custom_tree", Tree);
BI.createWidget({
type: "bi.example.select_custom_tree",
element: "#wrapper"
})