我正在尝试在树状面板中执行拖放事件,但有一些限制。 我有两个树视图,我需要有一些限制将右树的内容拖到左侧树。 1)我需要检查拖动的项目是否在左侧树上。如果是,则不允许任务完成 2)如果拖动的项目有子项,则应显示有关具有子节点的节点的通知。如果用户单击是,则应允许复制所有节点,否则应仅允许父节点
我已经用javascript编写了如下代码(注意我使用razor作为用户界面)
function (node, data, overModel, dropPosition, dropFunction) {
var record = data.records[0].data;
var nodeElem = data.item;
//before dropping item to the destination tree view we have to check if the item already exists
var exists = (nodeElem.find('.completed').length > 0);
if(exists)
{
return false;
}
//validate hierarchy level and parent node
var target = overModel;
//target.parentNode.data.id
var depth=target.getDepth();
if ( depth > 1) {
if (target.data.id != record.parentId) {
return false;
}
}
//check for existing nodes
var destTree = Ext.getCmp('tpDestination');
var found = findChildNodes(record.id, destTree);//dind childnodes checks the presence of chiild node
if (found) {
Ext.Msg.alert({
title: 'Alert',
msg: "The destination tree contains one of it's child domain. Please remove it's children and retry.",
buttons: Ext.MessageBox.OK
});
return false;
}
//allow copy of nodes. it overrides the move functionality
data.copy = true;
//show the confirmation message, if the node has children.
var isLeaf = record.leaf;
if (!isLeaf) {
//wait until confirmation complete
dropFunction.wait = true;
Ext.Msg.confirm({
title: 'Confirm',
msg: "Do you want to copy children also?",
buttons: Ext.MessageBox.YESNO,
fn: function (btn) {
if (btn == 'no') {
data.copyChildren = false;
}
dropFunction.processDrop();
}
});
}
data.dropNode = data.records[0];
return true; };
完成是右侧面板的节点类,代码应该检查拖动的元素是否已经完成的类已经存在但是它不起作用我不知道 当用户单击否时,它仍会添加子节点上的所有节点