I am new to Ext JS. I work on a grid panel, in which when I select / select any of the rows, then certain data related to the selected row is displayed in the panel below the grid. Also, when the window is loaded, the first should be selected / highlighted by default. The grid and panel are currently displayed correctly. Even the data related to the selected row is displayed in the panel, but the row is not highlighted. I tried methods grid.focusRow(0)and grid.getRow(0).highlight(), but they do not work. Below is my code.
initComponent : function() {
var single = false;
var store = new Ext.data.XmlStore({
HttpUtil.syncCall(this.url, "GET", this.loadStore, store,this);
var acctTplMarkup = [
this.acctTpl = new Ext.Template(acctTplMarkup);
if (single == false) {
var gridView = new Ext.grid.GridView();
var colModel = new Ext.grid.ColumnModel([ {
header : 'Status',
dataIndex : 'status'
}, {
header : 'Message',
dataIndex : 'message'
} ]);
var selModel = new Ext.grid.RowSelectionModel({
singleSelect : true
});
grid = new Ext.grid.GridPanel({
...
listeners : {
render : function(grid) {
Ext.getCmp('check').store.on('load',function(store, records, options) {
grid.getSelectionModel().selectFirstRow();
});
}
}
});
}
...
if (single == false) {
grid.getSelectionModel().on('rowselect', function(sm, rowIdx, r) {
Ext.getCmp('check').acctTpl.overwrite(Ext.getCmp('detailPanel').body, r.data);
});
}
Ext.apply(this, {
...
listeners : {
'afterrender' : function(){
Ext.getCmp('check').acctTpl.overwrite(Ext.getCmp('detailPanel').body, this.store.getAt(0).data,true);
}
}
});
Check.superclass.initComponent.apply(this, arguments);
},
Data from the data warehouse is loaded and displayed correctly, but only the row is not highlighted. Can someone tell me where I was wrong?
source
share