PDA

View Full Version : EditorGridPanel default select top row at load



bryanevil
28 Jun 2010, 5:55 PM
Hi all

what is the easiest way to default the grid to select the top row after data load?

Is there any property in the grid to do that?

I find some solution but does not look elegant to me.
http://hamisageek.blogspot.com/2009/01/extjs-tip-select-first-row-when-grid-is.html (http://www.sencha.com/forum/showthread.php?89700-Grid-with-default-selection-of-the-first-row)
http://www.sencha.com/forum/showthread.php?89700-Grid-with-default-selection-of-the-first-row

seek
2 Jul 2010, 5:20 AM
http://www.sencha.com/deploy/dev/docs/source/RowSelectionModel.html#method-Ext.grid.RowSelectionModel-selectFirstRow

Condor
2 Jul 2010, 5:38 AM
And you can call selectFirstRow from the viewready event of the grid.

bryanevil
8 Jul 2010, 3:45 PM
And you can call selectFirstRow from the viewready event of the grid.

I added this, but is not working

var grid = new Ext.grid.EditorGridPanel({
loadMask: true,
store: CompanyInfoJsonStore,
columns: CompanyColomn,
stripeRows: true,
autoExpandColumn: 'CompanyName',
height: 300,
title: 'Company List',
// config options for stateful behavior
stateful: true,
stateId: 'grid',
sm: new Ext.grid.RowSelectionModel({ singleSelect: true }),
viewready: function () {
this.getSelectionModel().selectFirstRow();
},

Condor
8 Jul 2010, 9:07 PM
viewready is an event. You need to specifyit inside the listeners config option.