1. #1
    Sencha User
    Join Date
    Jul 2011
    Posts
    49
    Vote Rating
    0
    zakif is on a distinguished road

      0  

    Default 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.

    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){
                                });
                            }
                            
                        });
                        
                    }
                }
            )
    The error warning is as below:

    Code:
    this.getForm is not a function
    
    [IMG]chrome://firebug/content/blank.gif[/IMG]                    this.getForm().getEl().dom.action='notif/email/search/';
    Would you like to share any advice or solution to fix that?

    Thanks in advance.

  2. #2
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,669
    Vote Rating
    110
    tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all

      0  

    Default


    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(){
    Best regards
    Tobias Uhlig
    __________

    S-CIRCLES Social Network Engine

  3. #3
    Sencha User
    Join Date
    Jul 2011
    Posts
    49
    Vote Rating
    0
    zakif is on a distinguished road

      0  

    Default 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
                        
                    }
                }
            )

Thread Participants: 1

Tags for this Thread