Tree_2
//节点移动限制判断function itemTreeCheckItemAcceptance(node,source) { var sourceItemLevel;source.forInSelectedItems(function(item){sourceItemLevel = item.data.item.level;//这里可得到源节点的item中的值});var item = dijit.getEnclosingWidget(node).item;//目标节点/*if (item && (item.root || myStore.hasAttribute(item,"numberOfItems"))){ //myStore.hasAttribute(item,"numberOfItems")判断节点中是否有numberOfItems这个属性return true;}*///console.log();if (item && item.level <= 2 && parseInt(item.level) != parseInt(sourceItemLevel)){return true;}return false;}//添加结节function addItem(){//console.log(lastSelected)//记录已选择的节点,可在节点的单击事件中设置if(!lastSelected) {alert("请选择一个类别!!");return;}else if(lastSelected.level == 3){alert("只能在类别中添加联系人!!");return;}var pInfo = {parent: lastSelected,attribute: "children"};//添加的动作myStore.newItem({name: "abc", department : "abc", level : (parseInt(lastSelected.level)+1) ,id:globalId++}/* 这个是item的属性 */, pInfo);}