PDA

View Full Version : How to get data for Store from Servlet



user14
5 Dec 2011, 8:31 AM
created store to get data from servlet and would like those data to be in grid.
what am I dong wrong ? Servlet returns JSON data .

Ext.define('DQM2.store.Users', {
extend: 'Ext.data.Store',
reader: new Ext.data.JsonReader({
fields: ['id','name','email'],
root: 'users'
}),

autoLoad: true,

proxy: new Ext.data.HttpProxy({
type: 'ajax',
url:'GridServlet'

})

mitchellsimoens
5 Dec 2011, 12:48 PM
You should define reader and proxy like that...


Ext.define('DQM2.model.User', {
extend : 'Ext.data.Model',

fields : [
'id',
'name',
'email'
]
});

Ext.define('DQM2.store.Users', {
extend : 'Ext.data.Store',

model : 'DQM2.model.User',

constructor: function(config) {
Ext.apply(config, {
proxy : {
type : 'ajax',
url : 'GridServlet',
reader : {
type : 'json',
root : 'users'
}
}
});

this.callParent([config]);
}
});