Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8829343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:48:48+00:00 2026-06-14T07:48:48+00:00

I have tried this different ways, but still can’t get the filter to work.

  • 0

I have tried this different ways, but still can’t get the filter to work. My ext app lets user to choose a single state from a combobox, and the grid below displays more data on that selected “value”=state.. On select, the combobox fires a function that filters the store of the grid and updates the store…
this is my store for the grid…

var store = Ext.create('Ext.data.Store', {
        autoLoad: true,
        id: 'OurData',
        pageSize: 20,
        pageNumber: 1,
        remoteSort: true,
        fields: [
    { name: 'States' },
    { name: 'FullName' },
    { name: 'Capital' },
    { name: 'Population' }
    ],
        proxy: {
            type: 'ajax',
            url: 'GetState/getS',
            reader: {
                type: 'json',
                root: 'myTable',
               idProperty: 'States',
                totalProperty: '@count'
            }
        }
    });
    store.loadPage(1);

this is my combobox

xtype: 'combo',
                    id: 'iccombo',
                    scope: this,
                    store: this.Combostore,
                    fieldLabel: 'Short State',
                    displayField: 'States',
                    valueField: 'States',
                    typeAhead: true,
                    triggerAction: 'all',
                    queryMode: 'remote',
                    name: 'State',
                    labelWidth: 125,
                    anchor: '95%',
                    listeners: {
                        scope: this,
                        select: this.fireFilter
                    }

and this is where the filter should take place…

fireFilter: function (value) {

    // Get passed value
    this.selectedC = value.getValue();
    console.log('selectedValue: ' + this.selectedC);

    // Clear existing filters
    this.store.clearFilter(false);

    // Build filter

    var myfilter = Ext.create('Ext.util.Filter', {
        scope: this,
        filterFn: function (item) {
            var fieldNames = item.fields.keys;

            for (var j = 0; j < fieldNames.length; j++) {
                var fieldName = fieldNames[j];
                if (item.data[fieldName] != null) {
                    var stringVal = item.data[fieldName].toString();
                    if (stringVal != null && stringVal.toLowerCase().indexOf(value.toLowerCase()) != -1) {
                        return true;
                    }
                }
            }
            return false;
        }

    });
    // Apply filter to store
    this.store.filter(myfilter);
}

when I run the code, it display all data in the grid, and on selection of combobox, it still shows the same data..
For some reason, the code never runs through the filterFn… because my console.log doesn’t show up
this is what I got in firebug’s response

_dc     1352902173425
filter  [{"property":null,"value":null}]
limit   20
page    1
start   0

as you can clearly see, the selected ‘value’ is null, but my ‘console.log’ prints the value selected… I think the way I am getting the passed value and applying the filter is incorrect… can someone please take a look… thanks

UPDATE… I am able to get inside the function and my console.log shows all the fields… but once I get to the last if statement… I get this error

TypeError: value.toLowerCase is not a function

What am I doing wrong here? Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:48:49+00:00Added an answer on June 14, 2026 at 7:48 am

    In addition to dbrin’s anwser I also can’t understand why you are using remoteSort but not remoteFilter? You may also have a scope issue by using this.

    Anyway I would recommend you to extend a new combo type so that you are also be able to clear your filter if you have the need to. Here is an extension I have written for my own use. Note that the filtering itself needs to be implemented in the onSearch method, which can be either a remote or a local sort.

    Ext.define('Ext.ux.form.field.FilterCombo', {
        extend: 'Ext.form.field.ComboBox',
        alias: 'widget.filtercombo',
        /**
        * @cfg {string} recordField
        * @required
        * The fieldname of the record that contains the filtervalue
        */
    
        /**
        * @cfg {string} searchField
        * @required
        * The fieldname on which the filter should be applied
        */
    
        /**
        * @cfg {boolean} clearable
        * Indicates if the clear trigger should be hidden. Defaults to <tt>true</tt>.
        */
        clearable: true,
    
        initComponent: function () {
            var me = this;
    
            if (me.clearable)
                me.trigger2Cls = 'x-form-clear-trigger';
            else
                delete me.onTrigger2Click;
    
            me.addEvents(
    
                /**
                * @event clear
                *
                * @param {Ext.ux.form.field.FilterCombo} FilterCombo The filtercombo that triggered the event
                */
                'clear',
                /**
                * @event beforefilter
                *
                * @param {Ext.ux.form.field.FilterCombo} FilterCombo The filtercombo that triggered the event
                * @param {String/Number/Boolean/Float/Date} value The value to filter by
                * @param {string} field The field to filter on
                */
                'beforefilter'
            );
    
            me.callParent(arguments);
            // fetch the id the save way
            var ident = me.getId();
    
            me.on('select', function (me, rec) {
                var value = rec[0].data[me.recordField],
                    field = me.searchField;
                me.fireEvent('beforefilter', me, value, field)
                me.onShowClearTrigger(true); 
                me.onSearch(value, field);
            }, me);
            me.on('afterrender', function () { me.onShowClearTrigger(); }, me);
        },
    
        /**
        * @abstract onSearch
        * running a search on the store that may be removed separately
        * @param {String/Number/Boolean/Float/Date} val The value to search for
        * @param {String} field The name of the Field to search on
        */
        onSearch: Ext.emptyFn,
    
        /**
        * @abstract onFilterRemove
        * removing filters from the the
        * @param {Boolean} silent Identifies if the filter should be removed without reloading the store
        */
        onClear: Ext.emptyFn,
    
        onShowClearTrigger: function (show) {
            var me = this;
            if (!me.clearable)
                return;
            show = (Ext.isBoolean(show)) ? show : false;
            if (show) {
                me.triggerEl.each(function (el, c, i) {
                    if (i === 1) {
                        el.setWidth(el.originWidth, false);
                        el.setVisible(true);
                        me.active = true;
                    }
                });
            } else {
                me.triggerEl.each(function (el, c, i) {
                    if (i === 1) {
                        el.originWidth = el.getWidth();
                        el.setWidth(0, false);
                        el.setVisible(false);
                        me.active = false;
                    }
                });
            }
            // Version specific methods
            if (Ext.lastRegisteredVersion.shortVersion > 407) {
                me.updateLayout();
            } else {
                me.updateEditState();
            }
        },
    
        /**
        * @override onTrigger2Click
        * eventhandler
        */
        onTrigger2Click: function (args) {
            this.clear();
        },
    
        /**
        * @private clear
        * clears the current search
        */
        clear: function () {
            var me = this;
            if (!me.clearable)
                return;
            me.onClear(false);
            me.clearValue();
            me.onShowClearTrigger(false);
            me.fireEvent('clear', me);
        }
    });
    

    Here is an untested implementation of your combo. Please note that I cleaned up your filterFn but I didn’t make any further check.

    {
        xtype: 'filtercombo',
        id: 'iccombo',
        scope: this,
        store: this.Combostore,
        fieldLabel: 'Short State',
        displayField: 'States',
        valueField: 'States',   
        typeAhead: true,
        triggerAction: 'all',
        queryMode: 'remote',
        name: 'State',
        labelWidth: 125,
        anchor: '95%',
        // begin new parts
        recordField: 'States',
        searchField: '',
        clearable: false,
        onSearch: function (me, value, field) {
    
            // New part!
            var store = Ext.StoreMgr.lookup('YourStoreIdName');
    
            // Clear existing filters
            store.clearFilter(false);
    
            // Build filter
            var myfilter = Ext.create('Ext.util.Filter', {
            scope: this,
            filterFn: function (item) {
                var fieldNames = item.fields.keys,
                    fieldName, stringVal,
                    len = fieldNames.length,
                    j = 0;
    
                for (; j < len; j++) {
                    fieldName = fieldNames[j];
                    if (item.data[fieldName] != null) {
                        stringVal = item.data[fieldName].toString();
                        if (stringVal != null && stringVal.toLowerCase().indexOf(value.toLowerCase()) != -1) {
                            return true;
                        }
                    }
                }
                return false;
            }
        });
            // Apply filter to store
            store.filter(myfilter);
        }
    }
    

    I guess this should work too

    var myfilter = Ext.create('Ext.util.Filter', {
                scope: this,
                filterFn: function (rec) {
                    var fieldValue = rec[this.fieldName];
                    if (fieldValue && fieldValue === this.value)
                          return true;
                return false;
                }
            });
    

    I set this before two vars to mark them as from a external scope.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried to do this in many different ways but the most obvious
I have tried this a few different ways, but the result always seems to
I have tried this a few different ways and it always seems to fail.
I have tried this but it does not work (even if I specify .wav
I have tried this but it doesn't work: tell application Preview set myfile to
I am using jQuery fullcalendar plugin , I have tried altering this many different
i have tried this code to redirect a php page.but it s not working
I know this has been asked a million times before but i still can't
I have tried this: #define format(f, ...) \ int size = strlen(f) + (sizeof((int[]){__VA_ARGS__})/sizeof(int))
I have tried this to pass the information: Form1 frm1 = new Form1(); textBox1.Text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.