View Full Version : grid panel find next value in grid greater than X

6 Dec 2013, 8:13 AM
I have a grid panel with buffered renderer switched on, with the store sorted in ascending order using column colX which holds integer values.
I want to find the next row that has a colX value greater than my selected colX value.

//sort ASC by colX
grid.store.sort( [{property: 'colX', direction: 'ASC'}]);
// I want to find the index of the next row which has colX greater than 3
matchindex = find('colX', >3); //I don't know how to do this
//jump to that row.
grid.view.bufferedRenderer.scrollTo(matchindex, true);

I have tried to loop though the store but it get's kinda messy to loop though the pages with buffered rendered switched on especially when I sort it.

Any help would be much appreciated :)

6 Dec 2013, 8:43 AM
Would it not be better to perform this at the server where you have access to all the data instead the buffered data and the client and then compare the returned records at the client if needed?

6 Dec 2013, 8:48 AM
If I find my row in the database on the server side- do I have to go back to the view to find the row in question using that criteria?

I suppose what I'm saying is- should there be an easy link between the buffered store and the database it's based on.

6 Dec 2013, 8:59 AM
In not knowing your requirement and how many records you are trying to manipulate, it would be difficult to say what is the best approach, but yes .. you would have to recycle this at the client.

I was thinking of filter the data at the server vs trying to find random records on a buffered grid.

6 Dec 2013, 9:08 AM
I don't want to filter the data- I want to scroll to a row that has a cell value that is X greater than the selected cell.

so I don't actually want to change the store- I want to scroll to a row in my existing store.

6 Dec 2013, 9:21 AM
Ok, back to your issue .. is store.find() not working in your code?

8 Dec 2013, 6:57 AM
can I use store.find to find a value greater than x?It seems I can only use it to find an exact value.

8 Dec 2013, 7:46 AM
You can always us findBy() and create a function

store.findBy(function(record) {
if (record.get('colX') > 3) {
return true;

8 Dec 2013, 1:15 PM
Thanks Scott for getting back so quick. Do I put this in the store definition and then iterate though the store's records and call this to compare?