Filter clears selection

Grids for WPF Forum

Posted 6 years ago by Mike
Version: 18.1.0670
Platform: .NET 4.7
Environment: Windows 10 (64-bit)
Avatar

Hi,

I'm using a simple string filter on TreeListBox which is bound to a textbox. On filtering items the selected item property of the TreeListBox changes. Is there a way to keep the selected item until its changed by the user only? I've been looking for something like a "FilteringStarted" and "FilteringEnded" event so I can save/restore the selection.

Comments (8)

Answer - Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Mike,

If you look at the IDataFilter in the TreeListBox's DataFilter property that you set, that has a FilterChanged event that fires.  That event fires whenever the filter enabled state changes, or one of the properties on the filter changes that could trigger a filter.  Perhaps you could look at that and see if your filter's properties have been updated in a way to know when filtering has started/stopped?


Actipro Software Support

Posted 6 years ago by Mike
Avatar

Thanks, it is not perfect but I was able to find a workaround using your suggestion.

Posted 6 years ago by Darcy Davidson
Avatar

Hi,

I noted this behavior as well and also found a non-perfect work around.  In my case it was clearing a multiselection.  Maybe something for a future release?

D'Arcy

Answer - Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

This situation is tricky because there isn't a real true start/end of the filter.  The filtering mechanism is a basic interface.  Some filters are string-based, while others might run a code-based predicate over values.  In Mike's scenario, he's pretty much always got the filter on.  It's just that with an empty TextBox value, the filter is allowing everything through.  However he could just as easily have a delegate filter with complex code that we wouldn't know if it was filtering anything or not.  That's the main we can't really have a set of FilterStarted/FilterEnded events with the way you're thinking of them. 

We could have those events based on the IsFilterActive property value changing, but that wouldn't help in this scenario since the filter is always active.


Actipro Software Support

Posted 1 month ago by Chris
Avatar

I also encountered this problem. When I cleared the keywords in the text box, the selected items were lost.

Posted 1 month ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Chris,

I'm loading our TreeListBox Filtering QuickStart and I do these steps:

  1. Select the "Cuba" item.
  2. In the filter "Value" TextBox underneath that, type in "cuba".
  3. Click the "Is filter active" CheckBox in the options.
  4. Clear the "Value" TextBox.
  5. Uncheck the "Is filter active" CheckBox.

After all those steps, Cuba is still selected.  Can you tell us how to reproduce what you are seeing?


Actipro Software Support

Posted 1 month ago by Chris
Avatar

2. In the filter "Value" TextBox underneath that, type in "cubb".

There are no matches at this time, but when I clear the value, the original selection is gone. This behavior does not seem normal. I did not make any changes to the selection and it disappeared.

Posted 1 month ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Chris,

There are a lot of possible scenarios that could happen with filtering and selection and before considering any changes to logic, we should probably talk through them all.  In all cases, assume there is a pre-filter selection of "Cuba" in that sample.  What do you feel like the selection should be following each of these scenarios?

Scenario 1

  1. Type a "c" filter string that matches the selection, and activate the filter.
  2. Deactivate the filter.
Scenario 1b
  1. Same as Scenario 1 but after step 1, select "Canada".

Scenario 2

  1. Type a "c" filter string that matches the selection, and activate the filter.
  2. Change the filter to "cz".
  3. Deactivate the filter.
Scenario 2b
  1. Same as Scenario 2 but after step 1, select "Canada".
Scenario 2c
  1. Same as Scenario 2 but after step 2, select "Canada".

Scenario 3

  1. Type a "c" filter string that matches the selection, and activate the filter.
  2. Change the filter to "cz".
  3. Backspace over the "z" to restore the filter to "c".
  4. Deactivate the filter.

Scenario 4

  1. Type a "z" filter string that doesn't match the selection, and activate the filter.
  2. Deactivate the filter.

Scenario 5

  1. Type a "z" filter string that doesn't match the selection, and activate the filter.
  2. Change the filter to "c".
  3. Deactivate the filter.
Scenario 5b
  1. Same as Scenario 5 but after step 2, select "Canada".


Actipro Software Support

The latest build of this product (v24.1.3) was released 6 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.