Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ext Js: How to load a store from List<String>

This is my JSON data returned from the server. I am not seeing my combo getting loaded. What is wrong here?

{"suffixList":["-1","-2","-3"]}

Model:

Ext.define('ExtMVC.model.Suffix', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'suffix'}
    ]
});

Store:

 Ext.define('ExtMVC.store.Suffixes', {
        extend: 'Ext.data.Store',
        model: 'ExtMVC.model.Suffix',
        autoLoad : false,
        proxy: {
            type: 'ajax',
            url: 'http://'+window.location.host+'/populateCombo',
            reader: {
                type: 'json',
                root: 'suffixList'
            }
        }
    });

View:

{
                xtype:'combo',
                id: 'suffix',
                name: 'suffix',
                store   : 'Suffixes',
                displayField: 'suffix',
                valueField: 'suffix'
            }
like image 725
hop Avatar asked Dec 18 '25 21:12

hop


1 Answers

You can use an ArrayStore

new Ext.data.ArrayStore({
    fields: ['suffix'],
    data: {suffixList: ['-1', '-2', '-3']},
    proxy: {
        type:'memory', //'ajax'
        reader: {
            type: 'array',
            root: 'suffixList'
        }
    }
})
like image 149
wantok Avatar answered Dec 21 '25 12:12

wantok