商店仅包含“原始”属性中的数据

时间:2013-12-03 14:02:33

标签: asp.net-mvc-4 extjs extjs4.2

我在ExtJS中的商店遇到了奇怪的问题。我的ASP.NET MVC3控制器返回JSON:

enter image description here

我的商店:

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的实际情况:

enter image description here

2 个答案:

答案 0 :(得分:2)

尝试使用root: 'users'而不是rootProperty。如果未指定root,则默认为''

Sencha Docs

答案 1 :(得分:2)

SENCHA到底是怎么回事?! Sencha Touch 2总是说将所有内容都放在config中? 现在,当我在ExtJS中这样做时,一切都会破裂吗?

我从config: {}删除了所有内容,现在效果很好。