Chr*_*ris 2 tree drag-and-drop extjs listener
我有一棵树在extjs.我已经添加了拖放插件,并且这些功能在浏览器中运行正常,但我需要将拖放更改发送到我的数据库中吗?要做到这一点,我相信我应该听取drop事件,然后对我的后端进行ajax调用.我有一个checkchange事件,可以激活,但是一滴或者之前甚至似乎什么都不做.
这是我的树的配置,我做错了什么?
todotree = {
title: 'Tree Grid',
width: 600,
height: 400,
viewConfig: {
plugins: {
ptype: 'treeviewdragdrop'
}
},
store: new Ext.data.TreeStore({
storeId: 'treestore',
fields: [{
name: 'actionTitle',
type: 'string'
}],
proxy: {
type: 'ajax',
url: 'index.php/todo/listtree',
reader: 'json'
}
}),
rootVisible: false,
columns: [
{
xtype: 'treecolumn',
text: 'Title',
flex: 3,
dataIndex: 'actionTitle'
}],
listeners: {
checkchange: function(node, checked){
Ext.Ajax.request({
url: 'index.php/todo/togglecheck/' + node.data.recordId + '/' + checked,
success: function() {}
});
},
drop: function(){ alert("drop") },
beforedrop: function(){ alert("beforedrop") }
}
}
Run Code Online (Sandbox Code Playgroud)
提前致谢
编辑:我也试过这个配置无济于事.我不认为我理解这一切是如何工作的.
...
beforedrop: function(node, data, overModel, dropPosition, dropFunction){
alert("beforedrop");
dropFunction = function(){
alert('dropFunction');
};
}
...
Run Code Online (Sandbox Code Playgroud)
这些事件由TreeView触发,您将在Panel上添加侦听器.这应该工作:
todotree = {...
viewConfig: {
listeners: {
beforedrop: function () {}
}
}
}
Run Code Online (Sandbox Code Playgroud)