set initial form values
January 6th, 2009
Highline.manda.quicksearch.MandaQuickSearchForm=Ex t.extend(Ext.FormPanel,{
initComponent:function(){
this.entitytypecombo=new Ext.form.ComboBox({labelAlign:'top',lazyRender:fal se,id:'entityType',fieldLabel:'Select Transaction Type',tabIndex:1,store:new Ext.data.SimpleStore({fields:['id','name'],data:this.entitytypes}),
valueField:'id',typeAhead:'true',forceSelection:tr ue,displayField:'name',mode:'local',
triggerAction:'all',emptyText:'Select a transaction type...',forceSelection:true,typeAhead:true,select OnFocus:true});
this.totalassetscombo=new Ext.form.ComboBox({tabIndex:9,id:'totalAssetsOpera tor',labelAlign:'top',fieldLabel:'Total Assets $(000)',name:'assetstype',mode:'local',typeAhead:' false',allowBlank:false,width:150,valueField:'id', triggerAction:'all',selectOnFocus:true,displayFiel d:'value',store:this.totalassetsdatastore,forceSel ection:true});
this.on("afterlayout",function()
{
this.initForm();
}
,this);
Ext.apply(this,
{monitorValid:true,frame:true,border:false,width:' 800',labelPad:1,defaults:{labelSeparator:''},
items:[{layout:'form',border:false,labelPad:1,defaults:{l abelSeparator:''},labelAlign:'top',items:this.enti tytypecombo}
,{xtype:'fieldset',width:300,autoHeight:'true',tit le:'Transaction Status',items:{layout:'column',border:false,width: 'auto',items:[
{columnWidth:.3,layout:'form',border:false,labelPa d:1,defaults:{labelSeparator:''},labelAlign:'left' ,labelWidth:50,items:{tabIndex:6,checked:true,id:' pending',fieldLabel:'Pending',name:'pending',xtype :'checkbox'}}
,{columnWidth:.35,layout:'form',border:false,label Pad:1,defaults:{labelSeparator:''},labelAlign:'lef t',labelWidth:65,items:{tabIndex:6,checked:true,id :'completed',fieldLabel:'Completed',name:'complete d',xtype:'checkbox'}}
,{columnWidth:.35,layout:'form',border:false,label Pad:1,defaults:{labelSeparator:''},labelAlign:'lef t',labelWidth:65,items:{tabIndex:6,checked:true,id :'terminated',fieldLabel:'Terminated',name:'termin ated',xtype:'checkbox'}}
]}}
,{xtype:'fieldset',width:700,autoHeight:'true',tit le:'Date',items:{layout:'column',border:false,widt h:'auto',items:[
{columnWidth:.25,tabIndex:6,checked:true,id:'dateT ransaction',name:'dateTransaction',xtype:'combo',v alueField:'id',typeAhead:true,forceSelection:true, displayField:'name',mode:'local',triggerAction:'al l',emptyText:'Select a date type...',selectOnFocus:true,store:new Ext.data.SimpleStore({fields:['id','name'],data:this.dateTypes})}
,{columnWidth:.25,tabIndex:6,checked:true,id:'date Operator',name:'dateOperator',xtype:'combo',valueF ield:'id',typeAhead:true,forceSelection:true,displ ayField:'name',mode:'local',triggerAction:'all',em ptyText:'Select a date operator...',selectOnFocus:true,store:new Ext.data.SimpleStore({fields:['id','name'],data:this.dateOperators})}
,{columnWidth:.25,tabIndex:6,checked:true,id:'date Value1',name:'dateValue1',xtype:'datefield',format :'m/d/Y'}
,{columnWidth:.25,tabIndex:6,checked:true,id:'date Value2',fieldLabel:'and',name:'dateValue2',xtype:' datefield',format:'m/d/Y'}
]}}
,{layout:'column',border:true,width:'auto',items:[
{layout:'form', columnWidth:.5,items:{xtype:'fieldset',collapsible :true,width:350,autoHeight:true,labelPad:1,labelAl ign:'top',defaults:{labelSeparator:''},title:'Buye r',items:[
{tabIndex:6,checked:true,id:'buyerName',fieldLabel :'Buyer Name',name:'buyerName',xtype:'textfield'}
,{tabIndex:6,checked:true,id:'buyerState',fieldLab el:'State',name:'buyerState',xtype:'combo',valueFi eld:'id',typeAhead:true,forceSelection:true,displa yField:'name',mode:'local',triggerAction:'all',emp tyText:'Select a state...',selectOnFocus:true,store:new Ext.data.SimpleStore({fields:['id','name'],data:this.statelist})}
,{tabIndex:6,checked:true,id:'buyerRegion',fieldLa bel:'Region',name:'buyerRegion',xtype:'combo',valu eField:'id',typeAhead:true,forceSelection:true,dis playField:'name',mode:'local',triggerAction:'all', emptyText:'Select a region...',selectOnFocus:true,store:new Ext.data.SimpleStore({fields:['id','name'],data:this.regions})}
,{tabIndex:6,checked:true,id:'buyerInstType',field Label:'Institution Type',name:'buyerInstType',xtype:'combo',valueFiel d:'id',typeAhead:true,forceSelection:true,displayF ield:'name',mode:'local',triggerAction:'all',empty Text:'Select an institution type...',selectOnFocus:true,store:new Ext.data.SimpleStore({fields:['id','name'],data:this.insttypes})}
]}}
,{layout:'form', columnWidth:.5,items:{xtype:'fieldset',collapsible :true,width:350,autoHeight:true,labelPad:1,labelAl ign:'top',defaults:{labelSeparator:''},title:'Targ et',items:[
{tabIndex:6,checked:true,id:'targetName',fieldLabe l:'Target Name',name:'targetName',xtype:'textfield'}
,{tabIndex:6,checked:true,id:'targetState',fieldLa bel:'State',name:'targetState',xtype:'combo',value Field:'id',typeAhead:true,forceSelection:true,disp layField:'name',mode:'local',triggerAction:'all',e mptyText:'Select a state...',selectOnFocus:true,store:new Ext.data.SimpleStore({fields:['id','name'],data:this.statelist})}
,{tabIndex:6,checked:true,id:'targetRegion',fieldL abel:'Region',name:'targetRegion',xtype:'combo',va lueField:'id',typeAhead:true,forceSelection:true,d isplayField:'name',mode:'local',triggerAction:'all ',emptyText:'Select a region...',selectOnFocus:true,store:new Ext.data.SimpleStore({fields:['id','name'],data:this.regions})}
,{tabIndex:6,checked:true,id:'targetInstType',fiel dLabel:'Institution Type',name:'targetInstType',xtype:'combo',valueFie ld:'id',typeAhead:true,forceSelection:true,display Field:'name',mode:'local',triggerAction:'all',empt yText:'Select an institution type...',selectOnFocus:true,store:new Ext.data.SimpleStore({fields:['id','name'],data:this.insttypes})}
]}}
]}
],
buttons:[{text:'Reset Search',tooltip:'Click here to reset search back to its default',type:'button',handler:this.resetForm,scop e:this},
{formBind:true,text:'Run Search',tabIndex:0,tooltip:'Click here to run search',type:'submit',scope:this,
handler:this.runSearch
}],
keys:[{
key: Ext.EventObject.ENTER,
scope:this,
fn:this.runSearch
}
],
submit:Ext.emptyFn,
onSubmit:Ext.emptyFn
});
Highline.manda.quicksearch.MandaQuickSearchForm.su perclass.initComponent.apply(this,arguments);
},
/*/initEntity:function(rec,opts)
{
this.findById("entityType").setValue("MA_WHOLE");
this.runRawSearch();
},*/
initState:function(rec,opts)
{
// this.findById("state").setValue("");
},
initForm:function()
{
this.resetForm();
//this.entitytypedatastore.load();
//this.entitytypedatastore.on("load",this.initEntity,this);
},
resetForm:function()
{
this.findById("entityType").setValue("MA_WHOLE");
// this.findById("pending").setValue(true);
// this.findById("completed").setValue(true);
// this.findById("terminated").setValue(true);
this.findById("dateTransaction").setValue(1);
this.findById("dateOperator").setValue(1);
// this.findById("dateValue1").getValue("");
// this.findById("dateValue2").setValue("");
this.findById("buyerName").setValue("");
this.findById("buyerState").setValue("");
this.findById("buyerRegion").setValue("");
this.findById("buyerInstType").setValue("1");
this.findById("targetName").setValue("");
this.findById("targetState").setValue("");
this.findById("targetRegion").setValue("");
this.findById("targetInstType").setValue("1");
this.runSearch();
},
runSearch:function()
{
if (this.getForm().isValid()){
this.runRawSearch();
}
},
runRawSearch:function(){
this.resultsstore.baseParams={
entityType:this.findById("entityType").getValue()
,pending:this.findById("pending").getValue()?1:0
,completed:this.findById("completed").getValue()?1:0
,terminated:this.findById("terminated").getValue()?1:0
,dateTransaction:this.findById("dateTransaction").getValue()
,dateOperator:this.findById("dateOperator").getValue()
,dateValue1:this.findById("dateValue1").getValue()
,dateValue2:this.findById("dateValue2").getValue()
,buyerName:this.findById("buyerName").getValue()
,buyerState:this.findById("buyerState").getValue()
,buyerRegion:this.findById("buyerRegion").getValue()
,buyerInstType:this.findById("buyerInstType").getValue()
,targetName:this.findById("targetName").getValue()
,targetState:this.findById("targetState").getValue()
,targetRegion:this.findById("targetRegion").getValue()
,targetInstType:this.findById("targetInstType").getValue()
};
this.searchgrid.updateGrid();
}
});
The problem is on dateValue1, and datevalue2. The first time I run the search, it comes back with a string value, then after that, it is a date value. I tried to use getValue().format('m/d/Y'), but that fails the first time, because the getValue is just a string.
#If you have any other info about this subject , Please add it free.# |