在ExtJS拖放树上,使用drop或beforedrop监听器似乎不起火 [英] On an ExtJS drag and drop tree using the drop or beforedrop listeners dont seem to fire
问题描述
我有一个checkchange事件触发正常,但一个drop或beforedrop甚至似乎什么都不做。
这是我的树的配置,我做错了什么?
todotree = {
title:'Tree Grid',
width:600,
height:400,
viewConfig:{
plugins:{
ptype:'treeviewdragdrop'
}
},
store:new Ext.data.TreeStore ({
storeId:'treestore',
fields:[{
name:'actionTitle',
type:'string'
}],
代理:{
type:'ajax',
url:'index.php / todo / listtree',
reader:'json'
}
}),
rootVisible:false,
列:[
{
xtype:'treecolumn',
文本:'标题',
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)}
}
提前感谢
编辑:
我也试过这个配置无效。我不认为我明白这是如何工作的。
...
beforedrop:function节点,数据,overModel,dropPosition,dropFunction){
alert(beforedrop);
dropFunction = function(){
alert('dropFunction');
};
}
...
这些事件由TreeView触发,您正在面板上添加侦听器。这应该工作:
todotree = {...
viewConfig:{
listeners:{
beforedrop:function(){}
}
}
}
I have a tree in extjs. I've added the drag and drop plugin and those function fine in the browser but I need to send the dragged and drop change to my DB correct? To do this I believe I should listen for the drop event then make an ajax call to my back end. I have a checkchange event that fires OK but a drop or beforedrop even seem to do nothing.
Here is my tree's config, what am I doing wrong?
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") }
}
}
Thanks in advance
EDIT: I also tried this config to no avail. I don't think I understand how this is all supposed to work.
...
beforedrop: function(node, data, overModel, dropPosition, dropFunction){
alert("beforedrop");
dropFunction = function(){
alert('dropFunction');
};
}
...
Those events are fired by the TreeView and you are adding the listeners on the Panel. This should work:
todotree = {...
viewConfig: {
listeners: {
beforedrop: function () {}
}
}
}
这篇关于在ExtJS拖放树上,使用drop或beforedrop监听器似乎不起火的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!