-
4 Dec 2011 7:42 PM #1
Search Form Using Combobox, Datefield & Search Button on tbar
Search Form Using Combobox, Datefield & Search Button on tbar
Dear all,
I have these codes to build search form. Unfortunately, the result is still error.
The error warning is as below:Code:'->', 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){ }); } }); } } )
Would you like to share any advice or solution to fix that?Code:this.getForm is not a function [IMG]chrome://firebug/content/blank.gif[/IMG] this.getForm().getEl().dom.action='notif/email/search/';
Thanks in advance.
-
5 Dec 2011 12:59 AM #2
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?
Code:new Ext.Button( { text: 'Search', icon: 'img/icon_search.gif', scope: myForm, handler:function(){
-
5 Dec 2011 8:07 PM #3
ID and Ext.getCmp
ID and Ext.getCmp
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:
Code:'->', //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 } } )


Reply With Quote