This is a migrated thread and some comments may be shown as answers.

Issue when using search box and SelectedItem

2 Answers 214 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Cedric
Top achievements
Rank 1
Cedric asked on 19 Feb 2018, 02:29 PM

Hi,

I have some problems to keep selection when using the search functionality of the Grid.

To reproduce the problem:

     - use the BoundSelectColumn of the Telerik sdk sample

     - Hit Ctrl+f to make the search box visible

     - Type 'pool' in the search box and check the 'liverpool' row

     - Clear the search box => all row are displayed and liverpool is checked That's OK

     - Type 'nal' in the search box and check the 'Arsenal' row

     - Clear the search box => all row are displayed and Arsenal is checked but liverpool is not That's KO

 

Why the search functionality is clearing the isSelected property ?

How can i keep it's value between several search ?

 

Thanks

Ced,

2 Answers, 1 is accepted

Sort by
0
Accepted
Dilyan Traykov
Telerik team
answered on 22 Feb 2018, 11:23 AM
Hello Cedric,

Such behavior is expected and is by design, as using the search panel actually filters the control's inner collection and the items which are filtered out are actually removed from the SelectedItems collection in the process. To overcome this, you will need to manually keep track of the selected items, possibly in the TextChanged event of the search panel's TextBox and add these items to the SelectedItems collection afterwards in the DataLoaded event of the control. The same approach can be used with the Filtered event to handle the case when filtering is applied through the filtering control rather than the search panel.

However, there is an additional complication with removing the persisted items. A possible approach can be to define a boolean flag, set it to False in the DataLoaded, remove the items from the persisted collection in the SelectionChanged event and set the flag back to True in the CollectionChanged event of the Items collection of the RadGridView control.

For your convenience, I'm attaching a sample project to demonstrate what I have in mind. Please note that this may not cover all use-cases, but feel free to contact me again if any issues do occur.

In addition, I'd like to let you know that I've logged a new feature request in our feedback portal to introduce two events of the search panel which will ease the aforementioned process. You can subscribe to the item to get notified about changes in its status and possibly modify the above  implementation once they are introduced.

I hope you find all of this helpful. Do let me know if you're satisfied with the approach I suggested.

Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Cedric
Top achievements
Rank 1
answered on 22 Feb 2018, 12:08 PM

Thanks Dilyan,

Your workaround work in the test project but i won't use it because:

- I have to set your PersistSelectionBehavior on all the grids in my application to correct this behavior

- I'm not sure it will work if several grids are used on the same window

- and i don't agree with 'Such behavior is expected and is by design'. For me, the selection state is between the user and my application, and in this case neither ones have changed the selected state of the row

 

There is too many issues or 'expected behavior' with the selected items in the grid specifically in a mvvm application.

I prefer stop to use it.

I will stop using the search as you type functionnality and I will replace the GridViewSelectColumn by the GridViewCheckBoxColumn. 

I will open a new thread to have some help to customize the GridViewCheckBoxColumn because i have the same problems there : https://www.telerik.com/forums/center-checkbox-in-gridviewcheckboxcolumn#ZNHmx_syy0q7mf-K90p2VQ

 

Ced

 

Tags
GridView
Asked by
Cedric
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Cedric
Top achievements
Rank 1
Share this question
or