View Full Version : Combo box example

26 Sep 2007, 9:13 AM
Hello world.

I need a litte help.

Ive a ds that work correctly and load data in my combo box, but I need two thing:

1) Better way for query my ds
2) Include a blank value that reset my filter.

my code:

var comboBox = new Ext.form.ComboBox({
store: dsc,
validateOnBlur: false,
triggerAction: 'all',
emptyText:'Select a category...',

// I need to use collapse becasue change work only when lost focus... WHY????
comboBox.on("collapse", onFilteringBeforeCombo);

var onFilteringBeforeCombo = function(e) {
var value = comboBox.getValue();
if (value.length==0) {
} else {
value = value.replace(/^\s+|\s+$/g, "");
if (value=="")
ds.filterBy(function(r) {
return (r.get('category') == value)

My code is little dry ... can any help me?

26 Sep 2007, 9:42 AM

26 Sep 2007, 9:56 AM
Not 100% sure what you are trying to do... when the user selects a value from the combobox you want to filter a different datastore??

If that's the case use the onSelect event:

comboBox.on('select', function()
// Do your filtering here

To add a blank entry to your combobox's datastore (dsc):

dsc.on('load', function(store, records, options)
// This is assuming that your dsc contains only a name field
dsc.insert(0, new Ext.data.Record({name:''}));
}, this, {single: true});

Troy Wolf
26 Sep 2007, 10:00 AM
What you want to do does not sound like a standard type of interaction, but I'm not sure what exactly you want to accomplish. Can you try to clarify? Thanks.

27 Sep 2007, 12:18 AM
Thanks to all

I populate my combobox from a ds, for filer my grid, but what I want is a blank value for clear the ds filter.

27 Sep 2007, 12:26 AM
have a look here:
There is a thread in Examples on this (Grid Playground)

27 Sep 2007, 12:41 AM
Is not much simple add a value "View All" and insert it in the dropdown of combobox?