ext下拉框赋值

                    xtype: 'combo',
                    fieldLabel : ROLE_PROPERTY.status,  
                    name : 'status',
                    //id:'status_id',
                    store : new Ext.data.SimpleStore({  
                                fields : ['key', 'value'],  
                          data : [['0', '激活'], ['1', '未激活'], ['2', '停用']]
                         }),
                    displayField : 'value',  
                    valueField : 'key',  
                    mode : 'local',
                    typeAhead : true,  
                    forceSelection : true,  
                    triggerAction : 'all',  
                    width : 230,
                    selectOnFocus:true,
                    editable : false,

                    mode: 'remote'

---------------------------------------------------

由于第一次使用extjs今天用到给下拉框赋值问题,

刚开始是采用roleForm.form.findField('status').setValue(0),结果就是不行

纠结了很久,在网上也找了很多资料,可是终究不能用。郁闷。。。。

Ext.getCmp('status').setValue(0);这是大多数人都会采用的方法,可是在我这里各种试就是不行。

突然间改成roleForm.form.findField('status').setValue(0+"");就可以了。突然间明白了,原来js为弱类型语言,需要强制转换。
roleForm.form.findField('status').setValue(obj.toString());和上一句是同样的效果,这样写跟专业一点
于是写出来给保留一下。。。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章