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

Rendering GridView seems to clear saved SelectedItems setting

5 Answers 148 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 1
Stephen asked on 26 Jul 2016, 03:23 PM

Hi, 

 

I'm having persistent issues with the grid when I try to set a saved list of selected rows when loading data into the grid in my WPF project. 

The basic logic is as follows:

1. Load the ViewModel, get saved data and populate an observable collection for the ItemsSource property on the grid. 

2. Set the SelectedItems property in the same procedure

3. Explicitly call the property changed event for the selected items collection.

I have implemented a custom behaviour to allow the RadGridView to use the Extended selection option and retain all selected items, and it works perfectly in this project and others, when setting the collection in the UI and binding to the collection in the ViewModel. 

I put an OnCollectionChanged event onto my selected items collection, and while it gets called as expected when I set the items, it also seems to get called after the grid itself is rendered, which causes the saved selection to be lost. 

If I use only a single item, i.e. SelectedItem, this does not get lost, and if I set SelectedItem by using the first line in the collection before setting SelectedItems collection itself, the UI retains the first one, but wipes the others. 

I have tried a number of ways to work around this, including trying to fire an event after the selection is overridden but it's proving very tricky to get the right event, and anyway this behaviour should surely not be happening in the first place. 

I am attaching a sample project which demonstrates a simpler version of this scenario, with the same problems. 

Please advise.

5 Answers, 1 is accepted

Sort by
0
Stephen
Top achievements
Rank 1
answered on 26 Jul 2016, 03:27 PM
I am struggling to attach the sample project. The web form keeps refusing my zipped solution file, which is roughly 50kb in size, so not sure why it's not working. 
0
Stephen
Top achievements
Rank 1
answered on 28 Jul 2016, 04:33 PM
any replies please?
0
Ivan Ivanov
Telerik team
answered on 29 Jul 2016, 12:33 PM
Hi Stephen,

The public forum system support only jpg, gif, png file extensions for the attachment. To send us the project you can use our support ticketing system, which provides 24 hours priority support and it also support up to 20MB archive attachments.
As for the question itself, I tried to follow the steps that you provided, on my side, but I did not have any significant result. I believe that the sample project, which includes the custom selection behavior would help me fully understand the details.

Regards,
Ivan Ivanov
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Stephen
Top achievements
Rank 1
answered on 03 Aug 2016, 10:58 AM

Hi Ivan, 

 

Thank you for your response. I don't see the option to create a new ticket anywhere. Could you point me in the right direction and I would happily do this? 

 

0
Dilyan Traykov
Telerik team
answered on 04 Aug 2016, 08:02 AM
Hello Stephen,

You can open a new support ticket by navigating to the following page. Please let me know how this goes.

Regards,
Dilyan Traykov
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
Stephen
Top achievements
Rank 1
Answers by
Stephen
Top achievements
Rank 1
Ivan Ivanov
Telerik team
Dilyan Traykov
Telerik team
Share this question
or