Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select row in grid AFTER load grid? [closed]

Tags:

extjs

Model.getSelectionModel().selectRow(0) not work ...

like image 304
Bdfy Avatar asked Dec 30 '10 10:12

Bdfy


2 Answers

this.store = new Ext.data.Store({
    ...
    listeners: {
        load: function() {
            this.grid.getSelectionModel().selectFirstRow();
        },
        scope: this
    }
});

this.grid = new Ext.grid.GridPanel({
    ...
    store: this.store
});

Something like this should work, assuming this.store and this.grid exist, I'm sure you can adapt it.

like image 186
Lloyd Avatar answered Nov 13 '22 08:11

Lloyd


I am just reiterating Lioyd's answer.
Also make sure that you have configured RowSelection Model in grid.

var grid  = new Ext.grid.GridPanel({
              store: ....,
              sm: new Ext.grid.RowSelectionModel({singleSelect: true}),

              // other grid configurations goes here
              listeners: {
                render : function(grid){
                  grid.store.on('load', function(store, records, options){
                    grid.getSelectionModel().selectFirstRow();       
                  });                      
                }
               }
            })      
like image 2
shivashankar Avatar answered Nov 13 '22 07:11

shivashankar