有些时候Ext.form.FromPanel中的组件都写好了,但是初始化的时候需要给组件填写初始值,例如combobox,textarea等。
可以使用Ext.getCmp('combobox').setValue('value');来设置初始值。
但是这样设置初始值有个问题,就是如果form.reset();
设置初始值的combobox就会被清空,因为form最初被实例化的时候,combobox是没有值的。
此时在setValue后,增加一句话,即可保证reset到正确的值:
Ext.getCmp('combobox').originalValue = value;
------------------------------------
buttons : [ {
text : "查询",
scope : this,
iconCls : "btn-search",
handler :function() {
var f = Ext.getCmp("dalyTjsearchPanelForm1");
var s = Ext.Ajax.serializeForm(f.getForm().getEl());
var c = Ext.urlDecode(s);
var flexpage;
flexpage = document.getElementById("flexDalyTjSjPage");
var cond = "qvideoName,"+c.qvideoName+";qtype,"+c.qtype+";qcarriertype,"+c.qcarriertype
+";qincharge,"+c.qincharge+";qtakeposition,"+c.qtakeposition;
if(c.videoPieSearchFlag == "year"){
flexpage.callBackFlexDalyTjSj(cond+";qmakeDate,"+c.qmakeDateYear + ";qmakeEnd," + c.qmakeEndYear+"y");
}else{
flexpage.callBackFlexDalyTjSj(cond+";qmakeDate,"+c.qmakeDate + ";qmakeEnd," + c.qmakeEnd+"m");
}
}
}, {
text : "重置",
scope : this,
iconCls : "btn-reset",
handler : function() {
Ext.getCmp('qvideoName2').setValue('');
Ext.getCmp('qtype2').setValue('');
Ext.getCmp('qcarriertype2').setValue('');
Ext.getCmp('qincharge2').setValue('');
Ext.getCmp('qtakeposition2').setValue('');
Ext.getCmp('qmakeDate').setValue('');
Ext.getCmp('qmakeEnd').setValue('');
Ext.getCmp('qmakeDateYear').setValue('');
Ext.getCmp('qmakeEndYear').setValue('');
var cond = "qvideoName,;qtype,;qcarriertype,;qincharge,;qtakeposition,"
var flexpage;
flexpage = document.getElementById("flexDalyTjSjPage");
flexpage.callBackFlexDalyTjSj(cond+";qmakeDate,;qmakeEnd,m");
}
}]