PDA

View Full Version : Ext.data.Store:listeners:load is not working



Nandha kumar
21 Jun 2013, 10:09 PM
I am upgrading from extjs 3 to 4.2; I have to select the 1st row of the grid while loading the store. but the following code is not working as well. Please help me out on this. Advance thanks.

MyStore = Ext.create('Ext.data.Store', {
storeId:'confStore',
fields: [
{name: 'emp-id'},
{name: 'empname'}
],
listeners: {
'load': function() {
var grid = Ext.getCmp('grdMyConfig');
grid.getSelectionModel().select(0);
grid.fireEvent('rowclick', grid, 0);
gridConf.getView().refresh();
},
scope: this
}
});
var gridCfg={
id: 'grdMyConfig',
type:GRID,
x:"4%",
y:"8.5%",
width: "92.4%",
height: "45%",
store: MyStore,
columns:['EmployeeID', 'Name'],
columnWidths:["50%","50%"],
dataIndex:['emp-id', 'empname'] ,
singleSelection:true
};
MyStore.load(result);

Farish
23 Jun 2013, 10:58 PM
unless you have overridden the grid to take care of this, dataIndex should be inside the columns array in ExtJS 4.x. take a look at the example (http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.grid.Panel) in the API docs.

Also, what is gridConf in this code? should this be grid instead?


var grid = Ext.getCmp('grdMyConfig');
grid.getSelectionModel().select(0);
grid.fireEvent('rowclick', grid, 0);
gridConf.getView().refresh();

what problem exactly are you having?

Nandha kumar
24 Jun 2013, 4:09 AM
gridCfg is the grid configuration passing to the common framework; where i am creating the "grid.Panel".

Problem facing : When ever i load the store that assigned to this grid, the listener:load should trigger but it is not happening now.That means, while MyStore.loadData(result) it should call listener:load and trigger the code that you have mentioned above;

Farish
24 Jun 2013, 5:53 AM
put a console.log() or alert() in the load listener at the very beginning to see if it is fired at all. try to debug using Firebug in Firefox or in Chrome (press F12).