在ExtJS拖放树上,使用drop或beforedrop监听器似乎不起火 [英] On an ExtJS drag and drop tree using the drop or beforedrop listeners dont seem to fire

查看:613
本文介绍了在ExtJS拖放树上,使用drop或beforedrop监听器似乎不起火的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个树在extjs。我已经添加了拖放插件,这些功能在浏览器中很好,但是我需要将拖放更改发送到我的数据库正确吗?为了做到这一点,我相信我应该听取丢失事件,然后对我的后端进行ajax调用。
我有一个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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆