Reputation: 149
this is my code
var store = {
roles_store: new Ext.data.Store({
autoLoad: false,
proxy: new Ext.data.HttpProxy({
url: 'a/b/c',
}),
remoteSort: true,
baseParams: {
},
reader: new Ext.data.JsonReader({
totalProperty: 'total',
root: 'root',
fields:['roles']
}),
})
};
this is my json
{"total":3,"root":[{"roles":"A"},{"roles":"B"},{"roles":"C"}]}
If I wnat to add data into Ext.data.Store. How can I do?
(PS:Sorry,my English is not well. And my extjs is :http://docs.sencha.com/ext-js/3-4/#!/api/Ext.data.Store-method-addSorted)
Upvotes: 0
Views: 23257
Reputation: 80
This should work:
Ext.define('roles', {
extend: 'Ext.data.Model',
fields: [
{name: 'roles', type: 'string'}
]
});
var myStore = Ext.create('Ext.data.Store', {
model: 'roles',
proxy: {
type: 'ajax',
url : 'path/to/data/test.json',
reader: {
type: 'json',
root: 'root',
totalProperty: 'total'
}
},
autoLoad: true
});
Check the examples here: http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Store
For v3.4:
var store = new Ext.data.JsonStore({
autoDestroy: true,
url: 'path/to/data/test.json',
storeId: 'myStore',
autoLoad: true,
idProperty: 'roles',
root: 'root',
fields: ['roles']
});
You need to use the jsonstore: http://docs.sencha.com/ext-js/3-4/#!/api/Ext.data.JsonStore
Upvotes: 2