Reset an ExtJS Combo Box

It’s not quite as intuitive as you’d expect.

cb.store.removeAll();
// force the reload on trigger
cb.lastQuery = null;

The above assumes you keep your Ext.Form around, even after you close an Ext.Window containing the form. If the form is actually destroyed on close, the default, your Combo will be recreated anew. The above is more useful when, for example, an Ext.Window with a search form where you want to keep the selection state and you setValues() on a show event.

4 Comments

  1. Posted 6/5/2009 at 12:27 am | Permalink

    Thanks - This was helpful

  2. Alan Robertson
    Posted 8/27/2009 at 10:00 am | Permalink

    I had a similar problem where I wanted to mark a bunch of stores to be reloaded the next time their respective combo boxes were used. Since I was getting the stores via the Ext.StoreMgr, I did not have access to the combo box that each store was attached to, so I couldn’t set the combo box’s lastQuery to null.

    I found that the following also works:

    function clearStore( dataStore)
    {
    dataStore.removeAll();
    dataStore.totalLength = 0;
    }

    One would think this would have been done when the removeAll method was called, but it isn’t. Maybe that’s a bug.

  3. Posted 9/30/2009 at 7:07 am | Permalink

    I need only reload de data os my combo becouse the data alway came from ajax but my combo wwas caching the data os last ajax to solve it i need put a

    combo.store.reload();

    after my ajax function who chance the data section of combo box

  4. vbpian.js
    Posted 4/4/2011 at 12:10 am | Permalink

    Thanks for this, its been 4 days i search the solution to clear the combobox and i found nothing work until i read this, it solve my problem.

Post a Comment

Your email is never shared. Required fields are marked *

*
*