1. #1
    Sencha User
    Join Date
    Feb 2011
    Posts
    2
    Vote Rating
    0
    mistr_e is on a distinguished road

      0  

    Default Using Drag and Drop on a tree the beforedrop event doesn't seem to fire

    Using Drag and Drop on a tree the beforedrop event doesn't seem to fire


    I have a tree and I've added the drag and drop plugin. Those function fine in the browser but I need to send the dragged and drop changes 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 even that fires OK but a drop or beforedrop event 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');
    };
    }
    ...

  2. #2
    Sencha User
    Join Date
    Feb 2011
    Posts
    2
    Vote Rating
    0
    mistr_e is on a distinguished road

      0  

    Default


    I was missing the fact that drop and beforedrop are TreeView events and I was adding then to the tree panel. I should be adding them to my viewConfig.

    Hope this helps someone else.