我需要一个简单的例子来重新加载Extjs网格的数据存储,基本要求是用另一个json数组附加Extjs-json数据存储。请帮助我完成这段代码,以便在Extjs Grid面板中加载data2(json对象)。
Ext.onReady(function () {
var store = Ext.create('Ext.data.Store', {
storeId: 'employeeStore',
fields: ['name', 'seniority', 'department'],
groupField: 'department',
data: {
'employees': [{
"name": "Michael Scott",
"seniority": 7,
"department": "Management"
}, {
"name": "Dwight Schrute",
"seniority": 2,
"department": "Sales"
}, {
"name": "Jim Halpert",
"seniority": 3,
"department": "Sales"
}, {
"name": "Kevin Malone",
"seniority": 4,
"department": "Accounting"
}, {
"name": "Angela Martin",
"seniority": 5,
"department": "Accounting"
}, {
"name": "Angela Martin",
"seniority": 5,
"department": "Accounting"
}]
},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'employees'
}
}
});
Ext.create('Ext.grid.Panel', {
title: 'Employees',
store: Ext.data.StoreManager.lookup('employeeStore'),
columns: [{
text: 'Name',
dataIndex: 'name'
}, {
text: 'Seniority',
dataIndex: 'seniority'
}, {
text: 'department',
dataIndex: 'department'
}],
width: 520,
height: 275,
renderTo: Ext.getBody()
});
var data2 = {
'employees': [{
"name": "User1",
"seniority": 7,
"department": "Management"
},{
"name": "User2",
"seniority": 7,
"department": "Management"
}]
};
});
1条答案
按热度按时间wfauudbj1#
检查Ext.data。商店#添加文档以了解更多信息。
注:
Ext.getStore()
是e1d1e的快捷方式。