PDA

View Full Version : Store Load data



firstblood
6 Mar 2013, 10:29 PM
Ext.define("Base.store.BaseStore", {
extend: "Ext.data.Store",
proxy: {
type: 'ajax',
reader: {
type: 'json',
root: 'data',
idProperty: "id",
successProperty: "success",
messageProperty: "msg",
totalProperty: "total"
}
}
});




Ext.define("Script.model.system.SystemMenuModel", {
extend: 'Ext.data.Model',
fields: ["id", "name", "icon1", "icon2", "fatherId", "modelClass", "children"]
});


Ext.define("Script.model.system.SystemRoleModel", {
extend: 'Ext.data.Model',
fields: ["id", "roleName"]
});




Ext.define("Script.store.system.SystemMenuStore", {
extend: "Base.store.BaseStore",
model: 'Script.model.system.SystemMenuModel'
});


Ext.define("Script.store.system.SystemRoleStore", {
extend: "Base.store.BaseStore",
model: 'Script.model.system.SystemRoleModel',
url: "/Handler2.ashx"
});

//my grid
Ext.define("Script.view.system.SystemRoleGird", {
extend: 'Ext.grid.Panel',
store: null,
columns: [
{ text: 'id', dataIndex: 'id' },
{ text: 'roleName', dataIndex: 'roleName', flex: 1 }
]
});

//the service result "{success : true, data:[{id:1,roleName:'jack'},{id:2,roleName:'tom'}], total:18}"

Ext.onReady(function () {
var store1 = Ext.create('Script.store.system.SystemMenuStore');
var store2 = Ext.create("Script.store.system.SystemRoleStore");
store2.proxy.url = "/Handler2.ashx";


Ext.create("Script.view.system.SystemRoleGird", {
store: store2,
renderTo: Ext.getBody()
});
store2.load();
});
The problem is this
//var store1 = Ext.create('Script.store.system.SystemMenuStore');
If you do not create store1 so my grid load data and bind is the correct
If create the store1 so my grid can not bind data
Found by monitoring

if create store1 so
sotre2.model is Script.model.system.SystemRoleModel
but sotre2.proxy.model is Script.model.system.SystemMenuModel

Sorry my English is not good if you can answer this question I will be very grateful

mitchellsimoens
8 Mar 2013, 11:04 AM
I'm sorry, I know your English is not good but I'm not understanding your question.