PDA

View Full Version : Prevent filtering of combo box with local store



tm8747a
11 Aug 2014, 1:51 PM
I'd like to prevent what appears to be the default behavior when typing in a combo box where it filters the records that show in the list. Ideally, I'd prefer if it continued to show all records and scrolled down to the one selected as the user types (I have typeahead: true and editable: true). Is there any way to accomplish that with built-in configs, or will this require extending/modifying default behavior?

I would think the latter because looking at the doLocalQuery() function in ComboBox.js, it seems to always add a filter. But wanted to know if anybody has had to do this before reinventing the wheel.

skirtle
12 Aug 2014, 5:22 AM
This should get you started:

7la

tm8747a
13 Aug 2014, 7:07 AM
Thanks for the reply skirtle. Prior to that, I had come up with the following solution, which seems to work for me, not sure if there's any drawback to it. I guess there are many solutions to one problem, not sure if there's something about yours that's better. Also, I needed to add some code to scroll selected value into view, which didn't seem to happen otherwise.



Ext.define('overrides.form.field.ComboBox', {
override: 'Ext.form.field.ComboBox',


// Get rid of filtering when doing query, we don't want to hide any values from list
doLocalQuery: function(queryPlan) {
var me = this,
queryString = queryPlan.query;


// Expand after adjusting the filter unless there are no matches
if (me.store.getCount()) {
me.expand();
} else {
me.collapse();
}


me.afterQuery(queryPlan);
},

// Run the parent function and scroll selected value into view
onTypeAhead: function() {
var me = this,
displayField = me.displayField,
record = me.store.findRecord(displayField, me.getRawValue()),
boundList = me.getPicker();


me.callParent();


if (record) {
boundList.listEl.scrollChildIntoView(boundList.getNode(record));
}
}
});