- 注册时间
- 2014-5-15
- 最后登录
- 2021-5-27
- 阅读权限
- 10
- 积分
- 872
- 精华
- 0
- 帖子
- 209
|
dforce 发表于 2017-2-9 16:06
var allNode=[]
mini.parse();
把allNode定义到mini.parse()前,运行mini.parse()的时候就已经自动加载了 ...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>treedemo</title>
<script src="http://www.miniui.com/scripts/boot.js" type="text/javascript"></script>
</head>
<style type="text/css">
body{
margin:0;padding:0;border:0;width:100%;height:100%;overflow:hidden;
}
.red
{
color:red;
}
</style>
<body>
<ul id="tree" class="mini-tree" style="width:300px;padding:5px;"
showTreeIcon="true" textField="text" idField="id" expandOnLoad="true">
</ul>
<script type="text/javascript">
var list = [
{ id: "base", text: "Base"},
{ id: "ajax", text: "Ajax", pid: "base"},
{ id: "json", text: "JSON", pid: "base"},
{ id: "date", text: "Date", pid: "base"},
{ id: "control", text: "Control", pid: "base"},
{ id: "forms", text: "Forms", pid: "base"},
{ id: "button", text: "Button", pid: "forms"},
{ id: "listbox", text: "ListBox", pid: "forms"},
{ id: "checkboxlist", text: "CheckBoxList", pid: "forms"},
{ id: "lists", text: "Lists"},
{ id: "datagrid", text: "DataGrid", pid: "lists" },
{ id: "tree", text: "Tree", pid: "lists" },
{ id: "treegrid", text: "TreeGrid ", pid: "lists" }
];
var allNodes = [];
var allButtons = [];
mini.parse();
var tree = mini.get("tree");
tree.loadList(list, "id", "pid");
var buttonNode = tree.getNode('button');
var listboxNode = tree.getNode('tree');
allButtons.push(buttonNode);
allButtons.push(listboxNode);
//tree.on('load', function(e){
$.each(allButtons, function(i, item){
tree.bubbleParent(item, function(data){
allNodes.push(data);
})
})
//})
tree.on('drawnode',function(e){
$.each(allNodes, function(i, item){
if(item.id == e.node.id){
e.nodeStyle = 'color:red;';
}
})
});
</script>
</body>
</html> |
|