Ext.form.ComboBox 设置默认值 value 和text都有对应值

来源:互联网 发布:小米5数据网络不稳定 编辑:程序博客网 时间:2024/06/01 08:54

var store1=new Ext.data.Store({
                            proxy : new Ext.data.HttpProxy({url:'listQuestionType.action'}),
                            reader : new Ext.data.JsonReader({
                                totalProperty : 'totalProperty',root : 'root'},
                                            [{name : 'id',type : 'int'},
                                             {name : 'name',type : 'string'}
                                            ],['id','name'])
                            });
    store1.load();

   var typecombo=new Ext.form.ComboBox({
                        id:'typeco',
                        fieldLabel: '问题类型',
                        width:127,
                          //emptyText : '请选择项目类型',
                        hiddenName: 'question.type.id',
                        valueField :'id',
                        displayField: 'name', 
                        forceSelection :true,
                        lazyInit:false,
                           editable  : false,
                           store : store1 ,
                        triggerAction: 'all'
                    });
    store1.on('load', function() { 
             typecombo.setValue(1);  //这个值在store中应该存在
      });

原创粉丝点击