Tree_1
1. dijit.Tree 中的节点属性除固有属性外,还可以随意添加
{identifier: 'id',label: 'name',items: [{ id: '0', name:'李英夫', department : 'w3', children:[ {_reference: '1'}, {_reference: '2'}, {_reference: '3'} ] },{ id: '1', name:'Fruits',children:[ {_reference: '4'} ] },{ id: '4',name:'Citrus', children:[ {_reference: '5'} ] },{ id: '5', name:'Orange'},{ id: '2', name:'Vegetables'},{ id: '3',name:'Cereals'}]}
function testclick(item){ //这里的item就是对应json中item属性的 //lastSelected=item;//这是记录最后点击的节点,为了添加节点而设置 alert("工号:" + item.id + "\n姓名:" + item.name + "\n部门:"+item.department);}
<div data-dojo-id="catModel" data-dojo-type="dijit.tree.TreeStoreModel" data-dojo-props='store:myStore, query:{id: "0"}'></div><div id="collectionsTree" data-dojo-type="dijit.Tree" data-dojo-props='"class":"container", model:catModel, betweenThreshold:5, getIconClass:getIcon, //这个是可以改变节点样式的方法 onClick:testclick, //这个就是单击事件persist:false'></div> 还有这样的写法<div dojoType="dijit.Tree" id="itemTree"model="itemModel"dndController="dijit.tree.dndSource" checkAcceptance="dndAccept" checkItemAcceptance="itemTreeCheckItemAcceptance"dragThreshold="8"getIconClass="getIcon"persist="false"></div>