Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ComboBox with anyMatch search in ExtJS

I have a ComboBox with a remote store with local filtering.
Instead of the default filtering, by the first characters like %query, I want to filter with the contains/anyMatch mode like %query%.

I tried to solve this with the answers in the question: ExtJs: Search / Filter within a ComboBox, but it didn't worked.

Code:

var users = Ext.create('Ext.form.ComboBox',{
    displayField : 'userName',
    valueField : 'userName',
    queryMode : 'local',
    typeAhead : true,
    store : Ext.create('Ext.data.Store', {
        model   : 'User',
        proxy       : {
            type    : 'ajax',
            url     : './user/list',
            reader  : {
                type: 'json',
                root: 'data'
            }
        }
    });
});

Thanks!

like image 205
Tiago Sippert Avatar asked Jan 21 '26 18:01

Tiago Sippert


1 Answers

Use anyMatch config option since Ext 4.2.1. In earlier versions it looks like you'll need to override doQuery method in Ext.form.field.ComboBox just to be able to add that option to the filter instance you'll find in there:

me.activeFilter = new Ext.util.Filter({
    root: 'data',
    anyMatch: true, // <- add this
    property: me.displayField,
    value: queryString
});
like image 72
Greendrake Avatar answered Jan 23 '26 08:01

Greendrake



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!