Extjs 4 Combobox数据存储无法显示数据

时间:2013-09-21 23:50:24

标签: extjs extjs4

我正在使用Extjs 4.1,尝试为Combobox加载数据,但不起作用。我对hte json reader root / record有很强的怀疑。

定义了数据模型和存储,

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
});

ComboBox定义为此,

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

我确信restful webservice将返回数据

{"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 个答案:

答案 0 :(得分:0)

在您的阅读器中,将“记录”更改为“root”。这是一个小提琴,表明您当前的设置可以正常工作:https://fiddle.sencha.com/#fiddle/km

相关问题