" I would love to change the world, but they won't give me the source code " -- Unknown Geek
Monday, January 12, 2009
ExtJS Tip : Select the first row when grid is loaded
Let's say that you have a grid called "mygrid" and you would like the first row of that grid to be selected when the grid data is loaded. The following snippet of code should work ...
AD: It is worked but below modification has done in my code .....{ xtype:'grid', sm:sm, cm:cm, store:store, listeners:{ 'viewready':function(grid){ grid.getSelectedModel().selectFirstRow(); grid.fireEvent('rowClick', grid, 0); } } }
Thanks for ur post. It helped me a lot!!!
ReplyDeleteA slightly better option could be to use the Grid View helpers instead of firing an event:
ReplyDeleteExt.getCmp('mygrid').on('viewready', function(){
this.getSelectionModel().selectFirstRow();
this.getView().focusRow(0);
}, this, { single:true });
both don't work in my case -- the event itself is not fired .
ReplyDeleteThanks a lot for point solution
ReplyDeleteAD: It is worked but below modification has done in my code
ReplyDelete.....{
xtype:'grid',
sm:sm,
cm:cm,
store:store,
listeners:{
'viewready':function(grid){
grid.getSelectedModel().selectFirstRow();
grid.fireEvent('rowClick', grid, 0);
}
}
}
is this code also valid for extjs 4.0, actually i tried this, but its not working
ReplyDelete