PDA

View Full Version : Select and AutoScroll/Focus to a particular row of Grid.



ashu2289
7 Nov 2012, 3:07 AM
Which Grid event is most suitable for selecting/autoscrolling to a particular row of the Grid. Have a look at this:


grid.getSelectionModel().select(rowIndex);
grid.getView().focusRow(recordID);


Using focusRow and select method i am able to select and gaining focus to a particular row. But what event is most suitable for this situation. I have tested 'afterrender', 'viewready', 'refresh' of GridView and scrollershow event but none of them assure that this code will be run when my grid and scroller are ready.
In my case, when all the data is rendered in the grid after that the scroller rendering starts.
Doing the stuff in scrollershow handler with a setTimeout/delay of 2seconds solves my problem but i do not want to rely on such time which may vary according to network/internet/browser speed and performance.
and if the records would less than the pageSize, scrollershow would not be triggered.

Please suggest a way out to this.

tvanzoelen
7 Nov 2012, 4:36 AM
I always do this stuff in the stores load callbackfunction

ashu2289
7 Nov 2012, 4:41 AM
Data Store load does not ensure that my grid view is ready and thus i cant scroll through records. It might work but i do not feel this is preferred approach.
In my case as well it is not working.

tvanzoelen
7 Nov 2012, 4:48 AM
Why not first render your UI and then get the data? Load the store after your grid is rendered.

ashu2289
7 Nov 2012, 9:50 PM
Store load is fired when data is loaded in the grid and 'viewready' is fired when the grid view is ready. In other terms 'viewready' is fired after store load event and its responsibility is to ensure that data loaded in the grid is rendered as well.

Please note that there is difference between grid render and its view render. View render is triggered after the grid render events.