Results 1 to 8 of 8

Thread: apply filter to combobox store- works 2nd time

  1. #1

    Default apply filter to combobox store- works 2nd time

    Here is what I'm doing.

    I create a combobox at load time. Its store is loaded from disk via proxy.

    I create a formpanel at loadtime which contains the combobox.

    I call a function that applies a filter to the store used by the combobox. Then, it shows the window.

    The combobox shows the unfiltered list of values (even though firebug shows that the store only contains the filtered data).

    I close the window and open it again. The combobox shows the filtered store this time.

    I have attempted to get at the view object of the store, but it doesn't seem to exist.

    I just wonder when the combobox gets a snapshot of the store for displaying?

    By the way, my initial structure used lazy construction of the formpanel and the combobox, but this only worked the first time. The second time, the combobox was empty. This was a topic that I posted earlier this week.

    I'll post code soon.

    Comboboxes just always seem to give me fits...

  2. #2


    I believe the combo does its initial query in the render event.

  3. #3

    Default my code

    Here I am creating the 2 comboboxes and my window at load time.

    var letterCombo = new Ext.form.ComboBox(
    	    ,fieldLabel:"Choose a Letter" 
    	    ,store: dsLetter 
    	    ,valueField: 'formletterId'
    	    ,emptyText: "Please select a letter"
    	    ,listeners: {select:function(thisCombo, letterRec, idx) 
    	        loadEmailBody(letterRec, null);
    var absCombo = new Ext.form.ComboBox(
            ,fieldLabel:"Choose an Abstractor" 
            ,store: dsAbsc 
            ,valueField: 'abscountyId'
            ,emptyText: "Please select an abstractor"
            ,listeners: {
            select:function(thisCombo, absRec, idx) 
                var theForm = thisCombo.ownerCt.form;
                loadEmailBody(null, absRec);
     var absWin = new Ext.Window(
        layout:     'form'
        ,modal:     true
        ,shadow:    true
        ,width:     535
        ,height:    490
        ,plain:     false
        {   xtype:"form"
            ,id: 'absForm'
                {xtype:"hidden", name:"abscountyId"}
                ,{xtype:"hidden", name:"transactionId", id:"transIdFldId"}
                ,{xtype:"hidden", name:"today", id:"todayFldId"}
                ,{xtype: "textfield"
                ,fieldLabel:"Abstractor Email Address" 
                ,width: 200
                ,{xtype: "textfield"
                ,width: 352
            {text:"Send Abstract Request"
            ,tooltip:"This will send the email AND assign the selected abstractor to the current trasnaction." 
            ,handler: function()
                    // we also need to save the abstractor setting here- this will happen in the php
                    var theForm = absWin.getComponent('absForm').form;
                    var valsObj = theForm.getValues(false); // return obj
                        waitMsg: 'Sending abstract request...'
                        ,url: 'sendAbsEmail.php'
                        ,params: valsObj
                        ,method: 'POST'
                            Ext.MessageBox.alert('Warning','Trouble sending abstractor email...');
    //                                      ds.commitChanges();
                            var responseData = Ext.util.JSON.decode(response.responseText);
                            Ext.example.msg('Email sent','Abstract request email sent and<br>abstractor selected for this transaction', "");
                ,tooltip:"This will close this window without doing anything." ,handler:function(){ absWin.hide();} }
                ,tooltip:"This will assign the selected abstractor to the current trasnaction<br>(and will NOT send the email)." 
                ,handler:function(e){  absWin.hide();} }     
            {activate: function(theWin) 
                var theAbsCombo = Ext.getCmp("abstractorComboId");
                 // this does set the correct string in the
                // field but does NOT fire the select event, even tho the docs say it does. 
                // on this combo, the displayfield and valuefield are both the same, and I am setting 
                // it to one of the values in the store, yet that value doesn't get selected
                // experiment-, true); 
    Now, here is the function I call to display the window. In this function, I apply a filter to the store in hopes that the absCombo will show my filtered data.
    function doAbstractWindow(grid, rowIndex, cellIndex, e)
        if ( > 2)
            dsAbsc.filter("countyState",; // after doing this, 
            // firebug tells me that the store has the filtered data
            var theAbsCombo = Ext.getCmp("abstractorComboId");
              // this does set the correct string in the
            // field but does NOT fire the select event, even tho it is supposed to. 
            // Perhaps this is because it is not rendered yet
            // experimental --, true);
            Ext.MessageBox.alert('Warning','You have not selected a county for the property yet. Please right-click on the borrower name to set the address and county.');
        absWin.setTitle("Abstractor Info for File " + +;
        var theEditor = Ext.getCmp("emailBodyId");
        var theSubject = Ext.getCmp("subjectFldId");
        theSubject.setValue( + + ", " + 
        if (!gLetterRec)
            var theLetterCombo = Ext.getCmp("letterComboId");
            gLetterRec = dsLetter.getAt(0);
    So- there are at least 2 things not working as I understand they should.

    1. I filter the store for the absCombo before it is rendered- yet the first time it renders, it has the full data. Thereafter, it renders the correct data in the list

    2. I would like to have the combo set to the correct thing upon appearance. In the absCombo I do something on the select event. If I setValue of the absCombo (with a valid choice from the datastore), it shows the correct thing, but does not actually select that item, and does not fire the select event. I have tried doing this selection both before I show the window, as well as on the activate event of the window. Same effect both ways.

    Thanks to anyone who takes the time to look at this and respond.


  4. #4
    Ext User
    Join Date
    Mar 2008


    For the select method not firing the select event, the docs say to use setValue() and not select().
    Here's an excerpt from the API documentation:

    select( Number index, Boolean scrollIntoView ) : void
    Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire. The store must be loaded and the list expanded for this function to work, otherwise use setValue.

  5. #5

    Default setValue doesn't fire the event either

    Yes- in the code that I posted I am trying setValue and then there is an experimental select right after it. This was an experiment that I forgot to remove when I posted. The setValue did indeed set the value in the field, but didn't actually seelct anything or fire the event. I'm commenting out the select line in my post because it is a red herring.

    Thanks for the reply!

  6. #6

    Default combo problem in a window

    can you check if you have or not and "id" field in the combo
    and waht if ever you comment the "id:" line
    in my case i have a similar problem
    1st time thze window appears it works
    2nd time the combo only has 1 valus and i cna t change it
    this ONLY occur with the "id:" explicitely set.
    without id it works fine

    i noticed too that the combo size was changed at the 2nd time the window is set on by show()

    the problem is maybe something like the objects are not destroyed, or the wrong one is pointed....

  7. #7
    Ext User denkoo's Avatar
    Join Date
    Jan 2008

    Thumbs up Normaly solution is simply

    Add only

    PHP Code:

    in definition of your editor column for you combo to filter
    and all will be ok

  8. #8


    I am having this same problem. I tried adding lastQuery: '' to the config of the column which holds the ComboBox I want filtered but it did not work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts