PDA

View Full Version : Programmatically move rows in a grid



henrik
21 Jun 2007, 11:55 PM
Is it possible to programmatically move rows in a grid in a way such as grid.moveRow(fromIndex, toIndex).


Henrik

Animal
22 Jun 2007, 12:29 AM
You would have to manipulate the Store's cache of Record objects to change their positions. This is how in-browser local sorting is done.

Use http://extjs.com/deploy/ext-1.1-beta1/docs/output/Ext.data.Store.html#remove to remove a record

Perhaps there should be a remove(rowIndex) method!

But you can use http://extjs.com/deploy/ext-1.1-beta1/docs/output/Ext.data.Store.html#getAt to get the Record at the required rowIndex.

And http://extjs.com/deploy/ext-1.1-beta1/docs/output/Ext.data.Store.html#insert to put it somewhere else.

Remember that if you're moving it "down", the remove will shuffle them up by one, so you'll have to decrement the insertion position.