How to load data in memory in extjs .by using an ajax response.ajax response give an json data. when i try to load into paging grid it doesnt show anything .can any one you idea.its help full to me
var itemsPerPage = 10; // set the number of items you want per page
// i am creating a store to load data into memory
var store = Ext.create('Ext.data.Store', {
autoLoad: true,
fields:['id','name', 'email'],
pageSize: itemsPerPage, // items per page
proxy: {
type:'memory',
enablePaging: true,
reader: {
type: 'json',
root: 'users',
successProperty: 'success'
}
}
});
// i am creating a ajax request to get json data
Ext.Ajax.request({
url: 'app/data/users.json',
success: function(resp) {
var result = resp.responseText;
store.loadRawData(result);
},
});
// to view data in store
Ext.define('AM.view.user.list' ,{
extend: 'Ext.grid.Panel',
alias: 'widget.userlist',
title: 'All Users',
initComponent: function() {
Ext.create('Ext.grid.Panel', {
title: 'My Test Demo',
store:store,
columns: [
{ header: 'ID', dataIndex: 'id' },
{ header: 'Name', dataIndex: 'name' },
{ header: 'Email', dataIndex: 'email', flex: 1 }
],
width: 350,
height: 280,
dockedItems: [{
xtype: 'pagingtoolbar',
store:store, // same store GridPanel is using
dock: 'bottom',
displayInfo: true,
pageSize:5,
}],
renderTo: Ext.getBody()
});
this.callParent(arguments);
}
});
and my json data look like this
{
"success": true,
"users": [
{"id": 1, "name": 'Ed', "email": "ed@sencha.com"},
{"id": 2, "name": 'Tommy', "email": "tommy@sencha.com"},
{"id": 3, "name": 'Tommy', "email": "tommy@sencha.com"},
{"id": 4, "name": 'Tommy', "email": "tommy@sencha.com"},
{"id": 5, "name": 'Tommy', "email": "tommy@sencha.com"},
{"id": 11, "name": 'Ed', "email": "ed@sencha.com"},
{"id": 12, "name": 'Tommy', "email": "tommy@sencha.com"},
{"id": 13, "name": 'Tommy', "email": "tommy@sencha.com"},
{"id": 14, "name": 'Tommy', "email": "tommy@sencha.com"},
{"id": 15, "name": 'Tommy', "email": "tommy@sencha.com"},
{"id": 21, "name": 'Ed', "email": "ed@sencha.com"},
{"id": 22, "name": 'Tommy', "email": "tommy@sencha.com"},
{"id": 23, "name": 'Tommy', "email": "tommy@sencha.com"},
{"id": 24, "name": 'Tommy', "email": "tommy@sencha.com"},
{"id": 25, "name": 'Tommy', "email": "tommy@sencha.com"},
]
}