PDA

View Full Version : Focus on a specified grid line after a store reload...



greencavern
12 Aug 2010, 9:42 AM
Hi all,

When i load (or reload) a grid store, i would like to focus the grid view on the line i want to specify, directly after the load.

The grid have more than 200 hundred lines but only show 20 at a given time. The focus would allow me not to scroll manually to the x line.

So i made something like this :



//Afterload
gridStore.on('load', function(e) {
actualPosition=20;
gridStore.getSelectionModel().selectRow(actualPosition);
gridStore.getView().focusRow(actualPosition);
gridStore.getView().focusEl.focus();
gridStore.getView().focusCell(actualPosition, 1);
});
I left here (in this example) all the methods to focus I used on purpose. I know they do almost the same action.

When i try these lines in a button function, it works and it places the line in the view.
But it don't work just after the store load...

Is it a delay problem or something like that ?
Any idea to put the line wanted on the first position on the grid view ?

Thanks in advance !

ashaihullin
12 Aug 2010, 10:05 AM
as a variant you can configure callback property when calling load method:



this.store.load({
scope: this,
callback: function(){
this.getSelectionModel().selectRow(1);
}
});


it work's for me every time i reload the store...