0
votes

I have a problem with loading data from store. Please tell me what I do wrong. I am using 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. But if I have one store and one big model, data don't display.

I have a JSON like this:

{
"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: 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);

}
});
1

1 Answers

0
votes

The above should load urls1 into the store correctly, however, the data type is array. So the data is in the store but it is only not displayed in the grid as dataIndex points to that array.

You can create another model for urls and associate it with the master model.