我在ExtJS中的商店遇到了奇怪的问题。我的ASP.NET MVC3控制器返回JSON:
我的商店:
Ext.define('MyApp.store.Users', {
extend: 'Ext.data.Store',
config: {
// I know the model works
model: 'MyApp.model.User',
storeId: 'Users',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'users/read',
reader: {
type: 'json',
root: 'users'
// also tried this
rootProperty: 'users'
}
}
}
});
现在,当我将此商店连接到ExtJS 4.2.1
内的网格时,网格显示两行但没有数据。当我console.log(store)
时,我仅在raw property
内看到数据,而不是data property
内的数据。
有谁知道这是什么问题?为什么没有任何映射?网格的dataIndex也和Models字段相同(我用PHP做了一千次,我不知道这里的问题在哪里。)
我尝试过的另一件事。我在网格列中尝试了renderer: function(value) { console.log(value); }
,我刚刚获得undefined
。
编辑:这就是JSON的实际情况:
答案 0 :(得分:2)
尝试使用root: 'users'
而不是rootProperty
。如果未指定root
,则默认为''
。
答案 1 :(得分:2)
config
中?
现在,当我在ExtJS中这样做时,一切都会破裂吗?
我从config: {}
删除了所有内容,现在效果很好。