ExtJs combobox默认值问题

来源:互联网 发布:线割编程软件哪个好 编辑:程序博客网 时间:2024/06/06 00:46

第一种方式(这种方式,我在使用时,如果数据不是从后台传过来的就可以,如果是从后台传过来的就不行了,要使用第二种方式)、

//第一种方式: 第一种方式是从本地获取 mode:locatevar CountryCode = [      ['93','Afghanistan(93)'],      ['355','Albania (355)'],      ['213','Algeria (213)'],      ['684','American Samoa (684)'],      ['376','Andorra (376)'],      ['244','Angola (244)']   ]  var checkupperson = new Ext.form.ComboBox({              fieldLabel: '审核人',              name:'checkupperson',              forceSelection: true,              listWidth: 200,              store: new Ext.data.SimpleStore({                  fields: ['value', 'text'],                  data : CountryCode                  }),              valueField:'value',              displayField:'text',              typeAhead: true,              mode: 'local',              triggerAction: 'all',              selectOnFocus:true,//用户不能自己输入,只能选择列表中有的记录              allowBlank:false,              listeners:{               select:function(){                alert(this.value);               }              }          });    checkupperson.on('beforerender',function(){          this.value=376;    }); //第2种方式: 第一种方式是从本地获取 mode:remote var depCombo = new Ext.form.ComboBox({       fieldLabel:'部门',       allowBlank: false,       allowNegative: false,       triggerAction: 'all',       displayField :'depName',       valueField :'depId',       id:'test',               store: new Ext.data.JsonStore({                    fields: ['depId','depName'],                    url: '../combobox.do?action=getDepartmentComboBox',                    autoLoad : true,                    listeners :{                          load:function(){                              Ext.getCmp('test').setValue(17);                          }                     } //在此加一个这个玩意,就可以了,呵呵,是在jsonstore中加的,注意              }),       editable :false   });  

本文转载

0 0
原创粉丝点击