`
lihao312
  • 浏览: 479631 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

处理Extjs3+ Combox默认值问题

阅读更多
处理Ext.form.ComboBox默认值

1.对于 mode: 'local', 直接设置value即可
{xtype: 'combo', mode: 'local', store: new Ext.data.ArrayStore({
        fields: [ 'value',   'key'],
        data: [[1, 'item1'], [2, 'item2']] 
    }),
    valueField: 'value',
    displayField: 'key',
    triggerAction: 'all',
    value: 1
}


2.对于mode默认或者mode: 'remote', 可以在afterrender事件里面处理
{
xtype : 'combo',
name : 'testname',
store: new Ext.data.JsonStore({
        autoLoad: true,
        url:'myurl',
        fields: ['id','name']
}),
editable : false,
valueField : 'id',
displayField : 'name',
fieldLabel : 'Test',
listeners: {
	afterRender: function(combo) {
                //设置延迟加载
		setTimeout(function(){
				var count = combo.store.getCount();
				if(count > 0) {
					var record = combo.store.getAt(0);
					combo.setValue(record.data.id);
					combo.setRawValue(record.data.name);
				}
			}, 500);
	}					
},
anchor : '90%'
}
0
2
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics