简体   繁体   English

ExtJS-来自商店的数据无法加载

[英]ExtJS - Data from Store don't load

I have a problem with loading data from store. 我从商店加载数据时遇到问题。 Please tell me what I do wrong. 请告诉我我做错了。 I am using ExtJS 4.1. 我正在使用ExtJS 4.1。 Request sends properly, i haven't troubles like file not found or something like that. 请求发送正确,我没有遇到找不到文件之类的麻烦。 It also works if I had few stores, and any of this stores loading one 'data type' to his model, for example urls1. 如果我的商店很少,并且其中任何一个商店都将一种“数据类型”加载到他的模型中,例如urls1,它也可以工作。 But if I have one store and one big model, data don't display. 但是,如果我只有一间商店和一个大型模型,则不会显示数据。

I have a JSON like this: 我有一个像这样的JSON:

{
"root": {
    "tName": "name",
    "urls1": [{
            "url": "http:// ..... :09'"
        }, {
            "url": "http:// ..... :10'"
        }],
    "perS": "",
    "perD": "",
    "urls2": [{
            "url": "http:// ..... :0009'"
        }, {
            "url": "http:// ..... :0010'"
        }],
    "val2": "",
    "list2": [{
            "level": "lvl1"
        }, {
            "level": "lvl2"
        }],
    "types": [{
            "type": "type2"
        }, {
            "type": "type4"
        }],
    "accs": [{
            "login": "login",
            "pass": "p1",
            "port": "8858",
            "conType": "type3",
        }, {
            "login": "login3",
            "pass": "p13",
            "port": "88583",
            "conType": "type2",
        }]
}
}

My Model: 我的模特:

Ext.define('ACT.model.myModel', {
extend: 'Ext.data.Model',
fields: [
    {name: 'tname'},
    {name: 'urls1'}, 
    {name: 'psec'}, 
    {name: 'pday'},

    {name: 'urls2'}, 
    {name: 'list2'},
    {name: 'types'},

    {name: 'accs'}, 

]

}); });

My Store: 我的商店:

Ext.define('ACT.store.dataStore', {
extend: 'Ext.data.Store',
storeId:'mStore',
model: 'ACT.model.myModel',
autoLoad: true,

proxy: {
    type: 'ajax',
    url: 'resources/data/configuration/MyConfig.json',
    reader: {
    type: 'json',
    root: 'root',
    successProperty: 'success'
    }
}

}); });

and my initComponent function in view: 和我的initComponent函数在视图中:

initComponent: function() {

    var me = this;

    this.columns = [
    {
        xtype: 'checkcolumn',
        text: ' ',
        width: 100,
        sortable: false,
        hideable: false,
        allowBlank: false
    },
    {
        text: 'URL',
        width: '85%',
        dataIndex: 'urls1',
        sortable: true,
        hideable: false
    }]
this.callParent(arguments);

}
});

The above should load urls1 into the store correctly, however, the data type is array . 以上应该将urls1正确加载到存储中,但是,数据类型为array So the data is in the store but it is only not displayed in the grid as dataIndex points to that array. 因此,数据在存储中,但仅当dataIndex指向该数组时才显示在网格中。

You can create another model for urls and associate it with the master model. 您可以为URL创建另一个模型,并将其与主模型关联

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM