PDA

View Full Version : Store is loaded but grid is empty ...



aimad41
19 Jun 2014, 1:42 AM
Hi all,

I'm a extjs dev since the version 3, i have correct knowledge of this framework, version 4 as well, i have spend several hours at this time to understand what is happening exactly here, and nothing, no progress, really desesperate, here the sample code :

Briefly called a store on action, service return json object, proxy defined as rest, and bind to the grid, store is loaded after rendering grid because of action that trigger the load store



Ext.define('MyApp.view.sales.customer.create.AddressGridList', {
extend : 'Ext.grid.Panel',
xtype : 'addressgridlist',
width:620,
store : Ext.getStore('user.CustomerAddress'),
border : false,
listeners : {
render : function(cmp){
cmp.getView().bindStore(Ext.getStore('user.CustomerAddress'));
}
},
columns : {
items : [ {
text : 'N',
dataIndex : 'numVoie',
width : 40
},{
text : 'Type et nom de voie',
dataIndex : 'nomVoie',
width : 160
},{
text : 'Code postal',
dataIndex : 'zipCode',
width : 160
},{
text : 'Ville',
dataIndex : 'city',
width : 120
}],
defaults : {
baseCls:'lp-customergrid-griditem'
}
}
});

Ext.define('MyApp.model.user.CustomerAddress', {
extend: 'Ext.data.Model',
fields : [
'line1',
'line2',
'line3',
'line4',
'city',
'zipCode',
'numVoie',
'nomVoie',
'checkNumber'
],
proxy: {
type: 'rest',
url:MyApp.Constants.REST.ADDRESSVERIFICATION_ADDRESS,
noCache: true,
headers: {
'Accept': 'application/json'
},
reader: {
type: 'json',
root:'crmAddressDTOs',
successProperty:false
},
writer: {
type: 'json'
}
}
});

Ext.define('MyApp.store.user.CustomerAddress', {
extend: 'Ext.data.Store',
requires: 'SitcomSales.model.user.CustomerAddress',
model: 'SitcomSales.model.user.CustomerAddress'
});

object returned by service:

{ "crmAddressDTOs": [ { "line1": "", "line2": "", "line3": "34 RUE DE CAMBRAI", "line4": "", "city": "PARIS", "zipCode": "75019", "numVoie": "34", "nomVoie": "RUE DE CAMBRAI", "checkNumber": null } ], "errorMessage": "no errors", "info": null}




The grid is added to a panel, don't worried about that, it's correctly inserted to a container, in the controller, the store is load by calling the service with parameters and return the previous json object as shown to the code section.
Root property is defined as well in the proxy when defining model, as u can see we have juste one record, but the grid remain empty, this is not my first grid that i develop, so i'm trying to understand what is happening here, the grid should receive the "onload" event of the store, and logically redraw the view isn't it?

Did u see any error on my declaration, maybe i'm tired here..

Thanx in advance for your precious help

mdnaveed42
19 Jun 2014, 11:37 PM
Hi,

Looks like store isn't loaded.

Please check,
1. Is your store declared in app.js or try adding(in view) store : Ext.create('user.CustomerAddress')
2. Try adding autoLoad (http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.data.AbstractStore-cfg-autoLoad) for your store.


Thanks,
Md Naveed
\m/