2

我正在使用 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            
        }

我确信宁静的网络服务会像这样返回数据

{"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}
4

1 回答 1

0

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

于 2013-09-22T00:54:00.590 回答