TableFilter - 'Apply' button selects all rows matching search, regardless of state of checkboxes.

Issue #714 new
Simon Perkins
created an issue

When I type a search query in the box, I see the matching entries below. However if I uncheck some of the matching entries (before hitting 'Apply') and hit ‘Apply’, all of the search results are included in the table rows, including the entries which I unchecked.

See screenshot 1 for state immediately before I pressed 'Apply' and screenshot 2 for the state after.

Comments (7)

  1. Stefano Negri

    Am I correct in saying that the culprit is line 133 of FilterPanel.java?

    132                    if (searchMode) {
    133                        filterList.forEach(v -> v.selectedProperty().setValue(true));
    

    I have tried deleting it and behaviour seems correct to me. I played around a bit with SourceTree but I don't think I can create a pull request.

  2. Thomas Nield

    I probably won't have time to get to this for awhile, but I will review a PR if one comes in. This is a little tricky because it's a common workflow of searching and then applying the filter to all search results.

    One way to fix this is to de-select all things that fall out of the filter scope, but select them again if they come back in scope.

  3. Stefano Negri

    I have created this pull request from the bitbucket site. I honestly couldn't figure out a way to do it from sourcetree :-( I hope it is still in a state that can be reviewed and I haven't messed up with something in the process... sorry but I am new to hg and bitbucket.

  4. Stefano Negri

    "anything that falls out of the search will be unchecked."

    In this case, if there is a long list of elements and the user wants to look for a few elements to exclude (while keeping all the others selected) I would expect this to happen:

    • the user starts to type the name of the first element he wants to exclude
    • search results are shown (selected)
    • user de-selects his item of choiche
    • user clears the search string and finds that also all the other elements have been de-selected

    This use case is very similar to what @Simon Perkins originally described when he opened this issue and unchecking anything that falls out of the search doesn't seem to be the expected behaviour, to me.

    Or if the user simply wants to exclude one single item what would happen is (if I understand correctly your implementation):

    • user searches for the element typying the exact name
    • search return one single element
    • user de-selects this element and hits "Apply"
    • table is empty
    • :-(

    Just my two cents...

  5. Thomas Nield

    I think this behavior you are describing is going to backfire for users who come from Excel and expect it to work like an Excel filter. The way I've implemented it in the PR above which follows the Excel behavior.

    When you need to start fine-tuning your search to that degree, you might just want to define a setSearchStrategy() and train users to leverage your implementation for pattern-matching. For instance, you can use a regular expression, wildcards, or comma-separated values:

    tableFilter.setSearchStrategy((input,target) -> {
        try {
            return target.matches(input);
        } catch (Exception e) {
            return false;
        }
    });
    
  6. Log in to comment