PDA

View Full Version : ptype:gridviewdragdrop, submit records in new order



JohnJones357
21 Jul 2014, 6:35 AM
I'm using dragdrop plugin. If I rearrange the records then submit them, they still get submitted in the order they were in when store was loaded, and not the new reorganized order.

I checked the docs for gridviewdragdrop but I dont see a config or method() that will allow me to preserve the new order on submit.
http://docs-origin.sencha.com/extjs/4.2.2/#!/api/Ext.grid.plugin.DragDrop

Im using checkboxmodel on my grid and to pass records I simply use getSelection() then push the selected records in to an array inside the Ext.each method. Then I pass the array as a param.

Thanks

mitchellsimoens
29 Jul 2014, 10:01 AM
What do you mean "submit them"?

andreas-spindler
29 Jul 2014, 11:59 PM
Hi,

I had the same problem. I solved it by doing this:
- add a 'sortOrder' property to the model
- add a 'updateSortNo' function to the grids store

updateSortNo: function(){
this.each(function(record, index){
var orgNo = record.get('sortOrder');
if (orgNo != (index+1)){
record.set('sortOrder',''+(index+1));
}
});
}
- catching the 'drop' event on the grid

onDrop: function(node,data,overModel,dropPosition,eOpts){
this.getStore().updateSortNo(); //"this" refers to the grid
this.getStore().sort(); // the sorter is sorting on sortOrder
}

There might be better solutions, but this works for me.

Regards