2
votes

I am using Extjs 4.1, tried to load data for Combobox, but doesn't work. I have strong doubt about hte json reader root / record.

the data model and store are defined ,

Ext.define('tagModel', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'id', type: 'string'},
        {name: 'name', type: 'string'}
    ]
});

var tagStore = new Ext.data.Store({
    model: 'tagModel',
    proxy: {
        type: 'ajax',
        url: '/ExtjsWebApp/webresources/question/loadTags',
        reader: {
            type: 'json',            
            record : 'rtnList'
        }       
    },
    listeners: {       
        load: function(store, records, options){
            alert("success " +records.length);
        }             
    },
    autoLoad: true
});

the ComboBox is defined as this,

 {
            itemId: 'search_tag_fld',
            fieldLabel: 'Tag',
            xtype: 'combobox',
            displayField: 'name',  
            valueField: 'id',
            store: tagStore,
            queryMode: 'remote',
            multiSelect: true,
            anchor: '100%',           
            labelHeight: 300            
        }

I am sure that the restful webservice will return data as this

{"rtnList":[{"id":1,"name":"Java","active":"true"},{"id":2,"name":"J2EE","active":"true"},{"id":3,"name":"JMS","active":"true"},{"id":4,"name":"Design","active":"true"},{"id":5,"name":"SOA","active":"true"}],"successMsg":"success","errorMsg":"","time":"09/21/2013 18:34:55","sessionId":null,"userId":null}
1

1 Answers

0
votes

In your reader, change "record" to "root". Here's a fiddle that shows that your current setup will work just fine: https://fiddle.sencha.com/#fiddle/km