PDA

View Full Version : Search Form Using Combobox, Datefield & Search Button on tbar



zakif
4 Dec 2011, 7:42 PM
Dear all,

I have these codes to build search form. Unfortunately, the result is still error.




'->',
new Ext.form.ComboBox({
fieldLabel: 'User',
hiddenName:'id_user',
valueField:'id_user',
//store: storeItemType,
store: new Ext.data.JsonStore({
root: 'datax',
id: 'id_user',
fields: ['id_user', 'username']
,
proxy: new Ext.data.HttpProxy ({
url: 'user/user/get/'
}),
autoLoad : true
}),
displayField:'username',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Select a Username...',
allowBlank:true,
selectOnFocus:true,
//anchor : '-25'
})

,' ',


new Ext.form.DateField({
name: 'timestamp',
width: 100,
allowBlank: false
})

, ' ',

new Ext.Button(
{
text: 'Search',
icon: 'img/icon_search.gif',
handler:function(){
this.getForm().getEl().dom.action='notif/email/search/';
//simpleLogin.getForm().getEl().dom.method='POST';
var me = this;
this.getForm().submit(
{

method:'POST',
waitMsg:'Loading..',
success:function(){
Ext.MessageBox.alert('Status','Successfully saved',function(btn,text){
if(btn =='ok'){
me.windowX.user_grid.load({params:{start:0, limit:20}});
me.windowX.close();
}
});
},
failure:function(){
Ext.Msg.alert ('Status','Fail Saved',function(btn,text){
});
}

});

}
}
)

The error warning is as below:


this.getForm is not a function

chrome://firebug/content/blank.gif this.getForm().getEl().dom.action='notif/email/search/';

Would you like to share any advice or solution to fix that?

Thanks in advance.

tobiu
5 Dec 2011, 12:59 AM
the scope of a button handler points to the button itself by default.
how should it know of a form created somewhere else without pointing to it?



new Ext.Button(
{
text: 'Search',
icon: 'img/icon_search.gif',
scope: myForm,
handler:function(){

zakif
5 Dec 2011, 8:07 PM
Thanks a lot for your reply, tobiu. I follow your clue. Now it's just solved.

First, I have to assign id for every form elements (both combo & datefield).
Second, I have to getCmp those value from every form elements aforementioned.

So here are the complete codes:


'->', //right alignment
new Ext.form.ComboBox({
fieldLabel: 'User',
hiddenName:'id_user',
valueField:'id_user',
id: 'userid', //assigned id
store: new Ext.data.JsonStore({
root: 'datax',
id: 'id_user',
fields: ['id_user', 'username']
,
proxy: new Ext.data.HttpProxy ({
url: 'user/user/get/'
}),
autoLoad : true
}),
displayField:'username',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Select a Username...',
allowBlank:true,
selectOnFocus:true,
//anchor : '-25'
})

,' ',

new Ext.form.DateField({
name: 'dateaction',
id: 'dateid', //assigned id
width: 100,
allowBlank: false
})

, ' ',

new Ext.Button(
{
text: 'Search',
icon: 'img/icon_search.gif',
handler:function(){

sms_store.clearFilter();
var searchU = Ext.getCmp("userid").getValue(); //got value
var searchT = Ext.getCmp("dateid").getValue().format('Y-m-d'); //got value
sms_store.filterBy(function(record, id) {
return (record.get('id_user') == searchU) && (record.get('timestamp') == searchT);
}); //search result is obtained by filtering

}
}
)