【问题标题】:ExtJS - Data from Store don't loadExtJS - 来自商店的数据不加载
【发布时间】:2014-05-27 01:21:11
【问题描述】:

我在从商店加载数据时遇到问题。请告诉我我做错了什么。我正在使用 ExtJS 4.1。 请求发送正确,我没有找不到文件或类似的问题。如果我的商店很少,并且这些商店中的任何一个都将一种“数据类型”加载到他的模型中,它也可以工作,例如 urls1。但是如果我有一个商店和一个大模型,数据就不会显示。

我有一个这样的 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",
        }]
}
}

我的模特:

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'}, 

]

});

我的商店:

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'
    }
}

});

以及我的 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);

}
});

【问题讨论】:

    标签: javascript extjs


    【解决方案1】:

    上面应该正确地将urls1加载到存储中,但是数据类型是array。所以数据在存储中,但它只是没有显示在网格中,因为dataIndex 指向该数组。

    您可以使用主模型为 urls 和 associate 创建另一个模型。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-02
      • 1970-01-01
      • 2020-04-14
      • 2013-02-03
      • 1970-01-01
      • 2015-05-26
      • 2013-03-17
      • 2012-03-11
      相关资源
      最近更新 更多