[GH #9290] Issue with Filtering by Value

Tags: #<Tag:0x00007efc652384e0> #<Tag:0x00007efc65238350>

Hello,

I’m not sure if I’m missing something but values do not return to the table if filter by value is used in after another filter.

If I filter in column 1 and then filter by value in column 2 everything works as expected. However when I go back to column 1 and undo the filter it does not appear back in the table. Instead I then need to go to column 2 and check the box that now appears in there that correlates to the same rows filtered out in column 1.

I know filter by value holds a list values that do not match the ones checked out, however it appears as though it does not hold on to the values previously filtered out (this partially makes sense as it doesn’t show values not currently listed in the table).

Is there a way around this that I am missing?

Thank you

Hi @kyle.trottier

I tried to recreate your issue, but I couldn’t get the results that you’re describing. You can check my demo here: https://jsfiddle.net/aszymanski/jrfqm9t1/

Can you tell me what version of Handsontable you use?

Hello,

I’m Currently on 11.0.1 but it works in in the demo which uses 11.1.
Demo: https://jsfiddle.net/kjtrottier/yj17frg0/5/

I added some comments in the javascript section on how to replicate the issue.

Hi @kyle.trottier

Thanks for the instructions. In the description in this example you can find correct steps to make it work properly:

https://jsfiddle.net/sxgLvtj3/

Do let me know if that helps you.

Hello @adrian.szymanski,

Thanks for the reply but the issue is that the what I am working on is intended for others to use. So I cannot know what the user will pick and both options (by value & by condition) are needed/useful.

The issue comes with using both filter types, so only using one does not really help all that much.

Thank you

Hi @kyle.trottier In your last demo you wrote that to replicate the issue one has to use filter by value on the B column with the value of 22. But there is only one row that meets the requirements based on your dataset

  data: [
    [11, 12, 13, 14],
    [21, 22, 23, 24],
    [31, 32, 33, 34],
    [41, 42, 43, 44],
    [11, 52, 43, 34]
  ],

so no matter if A1 is given the

Filter by Condition -> Is Not Equal -> 11

filter or the filter is completely off, it will still logically return a single row. And with this dataset below

  data: [
    [11, 12, 13, 14],
    [21, 22, 23, 24],
    [11, 22, 23, 24], //another row with `22` in column `B`
    [31, 32, 33, 34],
    [41, 42, 43, 44],
    [11, 52, 43, 34]
  ],

you can see that the data alter when we use none filter for column A after adding filter by value to column B.

Hello @aleksandra_budnik,

I feel like the point I am trying to make is being over looked, as I was trying to provide a simple example of the issue I have encountered. So I’ll try to explain it a bit better using this data:

[11, 12, 13, 14],
[21, 22, 23, 24],
[11, 22, 23, 24],
[31, 32, 33, 34],
[41, 42, 43, 44],
[11, 52, 43, 34]

In Column A I decide to filter out 11 by whatever means:

  • Filter by value - 11
  • is not equal to 11 (The one I used for this example)
  • greater than 12

It doesn’t matter which way the table then becomes

[21, 22, 23, 24],
[31, 32, 33, 34],
[41, 42, 43, 44]

Then I decide to use filter by value in Column B, it does not matter what I chose as long as it is filter by value so for an example I’ll uncheck both 22 and 32 out the 3 presented options of (22, 32, 42).

This now makes the table:

[41, 42, 43, 44]

Now if I decide to change the filter in Column A, the response I would expect is not displayed,
so for this example I will change the filter by condition to none.
the returned table looks like this:

[41, 42, 43, 44]

However, the only filter left that I have implemented was in Column B which was filter by value 22 and 32, yet when I now open Column B, 12, 22, 32, & 52 are all unchecked.

12 and 52 automatically became unchecked because they were removed from the table from the first query. I never wanted to remove 12 & 52 but they just happened to be removed by querying 11 out of Column A. It makes sense to me that the table should look like this upon reverting the Column A filter:

[11, 12, 13, 14],
[41, 42, 43, 44],
[11, 52, 43, 34]

but based on how it works now looks like this:

[41, 42, 43, 44]

My original question was to find if there was a way around this, if this is a known issue, or if I am just missing something.

Thank you

Thank you for sharing the details. Now I see it.

To explain why this happens we need to check the examples of the addCondition() method as it is the one that works under the hood to attach the filters. Reference: https://handsontable.com/docs/api/filters/#addcondition

Starting point

shown
    [11, 12, 13, 14],
    [21, 22, 23, 24],
    [11, 22, 23, 24],
    [31, 32, 33, 34],
    [41, 42, 43, 44],
    [11, 52, 43, 34]
not shown
- 

Then we call

filtersPlugin.addCondition(0, 'gt', [11]);
filtersPlugin.filter();

and get

shown
    [21, 22, 23, 24],
    [31, 32, 33, 34],
    [41, 42, 43, 44],

not shown
    [11, 12, 13, 14],
    [11, 22, 23, 24],
    [11, 52, 43, 34]

then we call attach this condition

filtersPlugin.addCondition(1, 'by_value', [[42]]);
filtersPlugin.filter();

and we get

shown
    [41, 42, 43, 44]

not shown
    [11, 12, 13, 14],
    [21, 22, 23, 24],
    [11, 22, 23, 24],
    [31, 32, 33, 34],
    [11, 52, 43, 34]

And then we proceed with None for column A which is not explained in the documentation (I will report that on out Github board immediately!). But s we can find it in the Filters API it is a call to the removeConditions() method with 0 (A column index). Reference https://handsontable.com/docs/api/filters/#removeconditions

And here is the trap as 42 in the B column dataset is available only in one single row. So no matter if we use

filtersPlugin.addCondition(0, 'gt', [11]);
filtersPlugin.filter();

still

filtersPlugin.addCondition(1, 'by_value', [[42]]);
filtersPlugin.filter();

blocks the ability for all those rows to show

    [11, 12, 13, 14],
    [21, 22, 23, 24],
    [11, 22, 23, 24],
    [31, 32, 33, 34],
    [11, 52, 43, 34]

After doing that description I myself found it hard to specify what is happening and I truly feel that this is misleading. I will report the issue with the missing none description and a request to fill the documentation with some examples on multi-column filters.

Reported issue https://github.com/handsontable/handsontable/issues/9290

If you found anything else misleading or false please let me know.

Thanks for the info, I’ll look for updates in the future.