我的MVC如下:
MODEL:
Ext.define('test.model.mdlPerson', {
extend: 'Ext.data.Model',
fields: [
{ name: 'name' },
{ name: 'surname' },
{ name: 'email' }
]
});
STORE:
Ext.define('test.store.Person', {
extend: 'Ext.data.ArrayStore',
model: 'test.model.mdlPerson',
data: [
{ name: 'Edddd', surname: 'dfasd', email: 'ed@sencha.com' },
{ name: 'Tommy', surname: 'dfgdfgdfg', email: 'tommy@sencha.com' }
],
storeId: 'Person'
});
GridPanel视图:
Ext.define('test.view.GridPanel', {
extend: 'Ext.grid.Panel',
title: 'The GridPanel',
alias: 'widget.gridpanel',
itemId: 'gridPanelId',
store: 'Person',
initComponent: function() {
columns : [
{ text: 'Name', dataIndex: 'name' },
{ text: 'Surname', dataIndex: 'surname' },
{ text: 'E-mail', dataIndex: 'email' }
]
this.callParent(arguments);
}
});
控制器:
Ext.define('test.controller.GridPanel', {
extend: 'Ext.app.Controller',
stores: ['Person'],
models: ['mdlPerson'],
views: ['GridPanel'],
refs: [{
ref: 'gridpanel',
selector: 'gripanel'
}]
});
问题是商店无法加载。我也试过了getStore()方法,但没有出现。有人在这帮忙!非常感谢!!!
答案 0 :(得分:0)
你不需要控制器。 当硬编码数据时会自动加载。
你有app.js吗? 如果不在这里
Ext.application({
models: [
'mdlPerson'
],
stores: [
'Person'
],
views: [
'GridPanel'
],
name: 'test',
launch: function() {
Ext.create('test.view.GridPanel', {renderTo: Ext.getBody()});
}
});
答案 1 :(得分:0)
你可以替换extend:' Ext.data.ArrayStore' 至 extend:' Ext.data.Store'然后试试......