【发布时间】:2015-11-08 15:57:32
【问题描述】:
我正在学习 extJS 并尝试按照 this 和 that 指南创建简单的应用程序。
我的 app.js 文件:
sstore = new Ext.data.Store({
autoLoad: true,
fields: ['firstName', 'lastName', 'educationId', 'townId'],
proxy: {
type: "ajax",
url: "data",
reader: {
type:"json",
root: "users"
}
}
});
Ext.application({
name: 'Application',
autoCreateViewport: true,
controllers: ['MainController']
});
Viewport.js:
Ext.define('Application.view.Viewport', {
extend: 'Ext.container.Viewport',
layout: { type: "vbox", align: 'stretch' },
items : [{
xtype: 'mainList',
autoScroll: true
}]
});
List.js:
Ext.define('Application.view.List', {
extend: 'Ext.grid.Panel',
alias : 'widget.mainList',
title : 'Users',
store: sstore, // ***** LOOK HERE PLEASE *****
//store: 'Users',
columns: [
{ header: 'Имя', dataIndex: 'firstName' },
{ header: 'Фамилия', dataIndex: 'lastName' },
{ header: 'Образование', dataIndex: 'educationId'},
{ header: 'Город', dataIndex: 'townId'}
]
});
商店(Users.js):
Ext.define('Application.store.Users', {
extend: 'Ext.data.Store',
storeId: 'usersStore',
//model: 'Application.model.User',
fields: ['firstName', 'lastName', 'educationId', 'townId'],
autoLoad: true,
proxy: {
type: 'ajax',
url: 'data',
reader: {
type: 'json',
root: 'users'
}
},
onProxyLoad: function (aOperation) {
console.log('From store');
console.log(aOperation);
}
});
当我在我的 List.js 文件中更改 store: 'Users' 上的 store: sstore 时,它不会加载任何数据,而是在 app.js 文件中创建存储在 sstore 变量中,它工作正常。
我尝试过但没有帮助:
- 使用内存代理,
- 使用
store: Ext.data.StoreManager.lookup('usersStore'), - 后端数据没问题(因为
sstore工作正常)
我可以看到来自 Users.js 的商店正在加载(因为来自onProxyLoad 函数的控制台输出)。
这是我在浏览器中看到的:
完整的js应用生活here
我的查看文件是here
我正在使用 extJS 4.2
【问题讨论】:
标签: javascript extjs extjs4