[CLOSED] grid.store.isFilterd () always return true

  1. #1

    [CLOSED] grid.store.isFilterd () always return true

    Hello, On your example https://examples.ext.net/#/GridPanel...Header/Filter/

    Try App.GridPanel1.store.isFiltered() in inspect win.
    It returns false on initial load,
    Type something in filter box, App.GridPanel1.store.isFiltered() returns true
    Cancel filter, App.GridPanel1.store.isFiltered() still returns true. Should it be false?
    I need something to test if the user is filtering the store.
    Please advise.
    Thanks
    Last edited by fabricio.murta; Jan 21, 2020 at 2:45 AM.
  2. #2
    Hello Susan!

    The example highlights usage of components in headers for simple filtering tasks. If you read thru the example's code, you'll notice how it just uses ordinary form fields to act as each column's filter input; and add the ClearButton plug in. This somewhat mimics the FilterHeader plug in.

    You would also notice how it applies the filters; by calling a function defined in the same example which just blindly sets the filter. It is not a full-blown filtering component, but a simplified overview of one of the possible usages it can be applied to.

    If you move further down, you'll also notice how the filters "stack" in the grids' list of filter (call getFilters().getCount() instead of isFiltered() after you change the filter several times). Even if you fiddle with a single field, the count will grow over and over, even also if you empty the field.

    Again, the example focuses in highlighting the feature's basic usage. It is not intended to highlight a full filtering implementation.

    To have the behavior you want, you may choose three paths:

    — use a proper component (the FilterHeader linked above would be one)
    — have the applyFilter() function remove the filter whenever its content string is empty
    — have the applyFilter() function do nothing when the filter string is empty and remove the filter for the column's field when the ClearButton for that field is clicked.

    Furthermore, to properly handle filters, you'd better have a deeper knowledge of how the filter is laid about the code. I'm afraid some reading & research would be required to this matter. Basically, having a good grasp of what is an Ext.util.Filter to identify the right one among the list of active filters in the grid's store via Ext.data.Store.getFilters() should be all you need to know to properly handle changes in the contents of the GridFilters columns.

    As far as I could see, the actual FilterHeader plug in's example has the filters cleaned as we clear each header field.

    Hope this helps!
    Last edited by fabricio.murta; Jan 21, 2020 at 2:44 AM. Reason: Added a third path to follow but still counted two :)
  3. #3
    Got it. Thanks for your help! This issue is resolved.
  4. #4
    Thanks for the feedback, hope this helped!

    ..and I fixed the issue my lack of counting skills caused in the alternative paths I provided in the previous post. :)
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] getRowsValues({selectedOnly:true}) return empty selection
    By gets_gui in forum 2.x Legacy Premium Help
    Replies: 6
    Last Post: Dec 03, 2013, 12:37 PM
  2. Replies: 5
    Last Post: Nov 29, 2011, 7:22 PM
  3. [CLOSED] Checkbox return true/false
    By Jurke in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Oct 04, 2011, 5:42 AM
  4. Replies: 5
    Last Post: Jun 10, 2011, 6:35 PM
  5. Replies: 6
    Last Post: Jan 11, 2011, 3:38 PM

Posting Permissions