I'm learning extJS and trying to create simple application following this and that guides.
我正在学习extJS并尝试创建简单的应用程序,并遵循此指南。
My app.js file:
我的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'}
]
});
Store (Users.js) :
商店(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);
}
});
When I'm changing store: sstore
on store: 'Users'
in my List.js file, it's not loading any data, but with store created in app.js file, which lives in sstore variable, it works ok.
当我正在更改store:sstore on store:'Users'在我的List.js文件中时,它没有加载任何数据,但是在app.js文件中创建的存储,它存在于sstore变量中,它可以正常工作。
What I tried and it didn't help:
我尝试了什么,它没有帮助:
- using memory proxy,
- used
store: Ext.data.StoreManager.lookup('usersStore'),
- it's not problem with backend data (because
sstore
works fine)
使用内存代理,
used store:Ext.data.StoreManager.lookup('usersStore'),
后端数据没问题(因为sstore工作正常)
I can see that the store from Users.js is loading (because the console output from onProxyLoad
function).
我可以看到来自Users.js的商店正在加载(因为控制台输出来自onProxyLoad函数)。
This is what I see in a browser:
这是我在浏览器中看到的:
Full js app lives here
全js app住在这里
My view file is here
我的视图文件在这里
And I'm using extJS 4.2
我正在使用extJS 4.2
1 个解决方案
#1
0
This was really stupid. Problem was in onProxyLoad function. When I deleted it from store app worked as I expected.
这真是太愚蠢了。问题出现在onProxyLoad函数中。当我从商店应用程序删除它按照我的预期工作。
#1
0
This was really stupid. Problem was in onProxyLoad function. When I deleted it from store app worked as I expected.
这真是太愚蠢了。问题出现在onProxyLoad函数中。当我从商店应用程序删除它按照我的预期工作。