Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExtJs 4 - Drag and Drop in the same grid

Tags:

extjs

extjs4

How do you do reordering of grid rows in ExtJs 4 by drag and drop? And is it possible? I see there is an example for drag and drop grid rows between 2 grids in the ExtJs examples page, but I don't seem to be able to figure out how to use this and make it work in one grid only.

I'll appreciate your help.

Thanks.

like image 526
Vlad Avatar asked Jun 12 '12 07:06

Vlad


2 Answers

OK, so I just figured it out. It was quite simple actually... All I needed was to simply add

plugins: {
    ptype: 'gridviewdragdrop'
}

to the grid's viewConfig and it works just fine.

Please don't down-rate this question. I'm sorry I didn't search more for the answer before posting the question here and had to answer my own question, but hope the answer will help someone else if searching for a solution to the same problem.

like image 89
Vlad Avatar answered Nov 06 '22 12:11

Vlad


plugins: {
    ptype: 'gridviewdragdrop',dragText:'Reorder Rows'
},
// to save position  
listeners:{
    drop:function(){
        Ext.Ajax.request({
            url:'url-to-save-position',
            params:{
                value:Ext.encode(Ext.pluck(grid.getStore().data.items, 'data'))
            }
        })
    }
}
like image 27
iproute Avatar answered Nov 06 '22 11:11

iproute