树视图拖放处理程序

本文关键字:程序 处理 拖放 视图 | 更新日期: 2023-09-27 18:09:18

我试图在树面板中执行拖放事件,有一些限制。我有两个树视图,我需要拖动右树的内容到左树与一些限制。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; };

completed是右面板的节点类,代码应该检查拖动的元素是否有类完成,但它不工作,我没有线索当用户单击no时,它仍然沿着子节点添加所有节点

树视图拖放处理程序

以下是Ext.NET论坛上的相关讨论:
http://forums.ext.net/showthread.php?24387