2

ここに画像の説明を入力

私はJQXTree、サンプルHtmlコードを使用しています

<div id='treeA' style='float: left; margin-left: 0px;'>
<ul>
    <li id='home' item-selected='true'>Server</li>
        <li item-expanded='true'>Incoming Data
            <ul>
            <li>FTP Adapter</li>
            <li item-expanded='true'>RDBMS
            <ul>
                         <li draggable="true">ftpConnection1</li>
                         <li id='ftpConnection2'>ftpConnection2</li>
            </ul>
        </li>
    <li>NoSql Adapter</li>
    <li>RSS Adapter</li>
    <li>MQTT Adapter</li>
    <li>ZMQ Adapter</li>
    </ul>
   </li>
 </ul>
</div>

$('#treeA').jqxTree({ allowDrag: true, allowDrop: true,  theme: theme});

画像をドラッグftpConnection1すると、親 ID とその親 ID を取得する必要がFTP AdapterありIncoming Dataます。

ツリーで dragEnd イベントを使用します

$("#treeA").on('dragEnd', function (item) {  
            console.log(item);
       var droppedToolId = item.args.owner._dragItem.id;
       var parentId = item.args.owner._dragItem.parentId;
});

親IDを取得するため、ドロップするアイテムの親の親IDを取得する必要があります。

助言がありますか?

4

2 に答える 2

0

次のコード スニペットを試してください。

$('#treeA').jqxTree({ allowDrag: true, allowDrop: true, height: '300px', width: '220px', 
                dragEnd: function (item, dropItem, args, dropPosition, tree) {
                    if (item.level != dropItem.level && item.parentId != dropItem.parentId)
                        return false;
                }   
                oldParentId = item.parentId;
                newParentId = dropItem.parentId;          
        });

お役に立てれば!

于 2014-09-25T22:21:16.923 に答える