Extjs 如何将一些数据加载到Ext.data.Store
这是我的密码Extjs 如何将一些数据加载到Ext.data.Store,extjs,Extjs,这是我的密码 var store = { roles_store: new Ext.data.Store({ autoLoad: false, proxy: new Ext.data.HttpProxy({ url: 'a/b/c',
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']
}),
})
};
这是我的json
{“总计”:3,“根”:[{“角色”:“A”},{“角色”:“B”},{“角色”:“C”}]}
如果我想在Ext.data.Store中添加数据。我该怎么办
(注:对不起,我的英语不好。我的extjs是:http://docs.sencha.com/ext-js/3-4/#!/api/Ext.data.Store方法addSorted)这应该可以:
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
});
检查此处的示例:
对于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']
});
您需要使用jsonstore:
我的extjs是3-4:是一样的吗?