Vlad
Vlad

Reputation: 513

ExtJs 4 - Drag and Drop in the same grid

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.

Upvotes: 7

Views: 8985

Answers (2)

Vlad
Vlad

Reputation: 513

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.

Upvotes: 14

iproute
iproute

Reputation: 21

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'))
            }
        })
    }
}

Upvotes: 2

Related Questions