我正在使用树和&查询插件的treegrid:http://www.jeasyui.com/demo/index.php 我想要当前存在的拖放功能,但问题是我想要COPY节点而不是MOVING它。 另外我想在双击&上编辑treegrid的节点。保存在ENTER上。我可以编辑dbl上的节点点击但dnt知道如何捕获ENTER事件! 下面是我为编辑节点而实现的代码:
<table id="bomSubTree" style="width:600px;height:300px"> </table>
.......
$('#bomSubTree').treegrid({
height: 550,
//width:600,
dnd: true,
method: 'get',
treeField: 'text',
idField: "oid",
pagination: "true",
fitColumns: "true",
url: '/product_configurator/populate_sub_tree.json',
columns: [
[{
field: 'quantity',
title: 'Quantity',
width: 100,
editor: "numberbox",
align: "right"
}
]
],
frozenColumns: [
[{
title: 'Name',
field: 'text',
width: 500
}]
],
onDblClickRow: function (row) {
$(this).treegrid('beginEdit', row.oid);
}
});`
任何人都可以帮助我!?
答案 0 :(得分:0)
尝试执行以下操作:
将节点定义为可拖动时,将其revert选项设置为true。这意味着他们将回到原来的位置。
然后,修改ondrop功能,以便将源附加到您要定位的节点,就像在拖放演示的源代码中那样
onDrop:function(e,source){
if ($(source).hasClass('assigned')){
$(this).append(source);
} else {
var c = $(source).clone().addClass('assigned');
$(this).empty().append(c);
c.draggable({
revert:true
});
}
}
这基本上意味着您的节点将在拖动停止后返回到其原始位置,但无论何时停止拖动节点,都将被克隆并追加,并且还可以再拖动。