PDA

View Full Version : selecting the last inserted row



raj_plays
7 Apr 2010, 11:28 PM
Hi,
I have a Grid with an editor plugin.
After a row is inserted in the grid and the store is reloaded, I want to mark the new row as selected.
For this I need to be able to get the row with the max Id. I cannot simply select the last row because sorting is done on another field.
Help please..

Animal
8 Apr 2010, 1:46 AM
So, what's the problem? Find the record with the max id, and select it.

raj_plays
8 Apr 2010, 2:33 AM
Thanks for replying, Animal
I wanted to know if there is an easier way than
using store.collect('id') to get the array of ids and then getting the max id from that array

tonedeaf
8 Apr 2010, 2:49 AM
Math.max.apply(null, store.data.keys)

raj_plays
8 Apr 2010, 11:35 AM
That is perfect!
Thank you, tonedeaf