ExtJS Combobox 如何设置默认和取值问题

 

 

主要是在store 里监听load事件,store完成的时候,数据已经引用进来了。获取store第一条记录,设定为ComboBox 的默认值

        var poststore = Ext.create('Ext.data.Store', {
            model: 'State',
            listeners: {
                load: function() {
                var record = poststore.getAt(0).get('position_id');
                    SelectPostion.setValue(record);
                }
            },
            proxy: new Ext.data.HttpProxy({ url: '/web/wage/ajaxcityconfig.aspx?type=Pos' }),
            reader: new Ext.data.JsonReader({}, [
                                            { name: 'position_id' },
                                            { name: 'position' }
                                    ])

        });

 

// ComboBox with multiple selection enabled
var SelectPostion = Ext.create('Ext.form.field.ComboBox', {
    fieldLabel: '选择职位',
    labelStyle: 'width:80px;color:black',
    Style: 'color:black',
    multiSelect: false,
    displayField: 'position',
value: '',
    width: 320,
    labelWidth: 80,
    valueField: 'position_id',
    store: poststore,
 
    queryMode: 'remote'
});

poststore.load();

你可能感兴趣的:(function,url,ExtJs)