在Ext.tree.Panel中,编辑记录是通过rowediting插件完成的。 如何防止删除或编辑最上面的根记录?
以及如何禁止拖动除了childNode之外的最上面的记录?
拖动是使用treeviewdragdrop插件完成的。 下面是插件代码。
...
plugins: [{
ptype: 'rowediting',
clicksToMoveEditor: 1,
autoCancel: false,
listeners: {
afteredit : function (editor, context, eOpts ){
context.store.reload();
},
canceledit : function ( editor, context, eOpts ){
context.store.reload();
}
}
}],
viewConfig: {
plugins: [{
ptype: 'treeviewdragdrop',
containerScroll: true
}]
},
...
fiddle 中的示例,在文件 app/view/QuestionTree.js
最佳答案
只是为了添加到解决方案中,为了防止拖动最上面的记录,您还可以使用:
listeners: {
viewready: function (tree) {
var view = tree.getView(),
dd = view.findPlugin('treeviewdragdrop');
dd.dragZone.onBeforeDrag = function (data, e) {
var rec = view.getRecord(e.getTarget(view.itemSelector));
return rec.isLeaf();
};
}
}
关于javascript - 如何防止删除、编辑和拖动树中的记录。 Extjs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53519121/