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

RadGridView removes ColumnSortDescriptor

3 Answers 226 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Boardy
Top achievements
Rank 1
Veteran
Boardy asked on 08 Mar 2013, 10:10 AM
The RadGridView removes the ColumnSortDescriptor when there is no data to display. The result is that when there is data again, it isn't sorted any more.

My specific case is as follows: I have two grids. The second grid shows the items from a List<> property of the selected item in the first grid. When the second grid is sorted (either because I added a ColumnSortDescriptor in the constructor or because the column was clicked in the GUI) and in the first grid a row is selected that doesn't have any items in the List, then the second grid shows no items (correctly) and the sorting arrow disappears. After a row is selected that does have items in the List, the second grid shows these items, but the sorting is gone.

Is there a way to make this sorting more persistent?

Thanks in advance,
  Herre

[WPF2012Q3]

3 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 11 Mar 2013, 08:21 AM
Hi,

In general, all Sort-, Filter- and GroupDescriptors of the grid are automatically cleared in two cases:

1. The ItemsSource of the grid is assigned null, i.e. the grid is un-bound so to say.
2. The ItemsSource of the grid is assigned a collection which has a generic type that is different from the generic type of the previous collection that was the ItemsSource, i.e. if the grid was bound to IEnumerable<Apple> and then suddently someone assigns as the ItemsSource and IEnumerable<Cat>, we have to clear all descriptors since they might no longer be valid.

Is one of those happening in your case? In case it is, you would have to cache/save the descriptor somewhere and restore it on the grid after the change has happened.

If you still have problems, could you please open a new support ticket and send us a dummy sample project that demonstrates the problems that you are having. We will take a look at it to see what exactly is going on and what can be done in order to change this behavior.

I hope this helps.

Kind regards,
Rossen Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Boardy
Top achievements
Rank 1
Veteran
answered on 11 Mar 2013, 12:58 PM
Thanks Rossen, but neither is the case.

I create a testcase and at first could only confirm your suggestion.

Then I realised the difference: The objects in my "real" program are EntityObjects from a database and the property I said contains a List<> actually contains an EntityCollection<>. It appears this makes a difference. When a row is selected in the main grid where the SelectedItem has an empty collection (so it is not null, but has a count of 0), the sortdescriptor is removed.

Does this make sense to you now? Or should I open a support ticket as you suggested?
0
Rossen Hristov
Telerik team
answered on 11 Mar 2013, 01:04 PM
Hello,

Unfortunately, I cannot guess why that would change things. If you can open a support ticket and attach a very small dummy sample that would be great. You can use Northwind, AdvetureWorks or another dummy database for demo purposes.

As a workaround, you can try to check whether such a descriptor already exists in the SortDescriptors collection on every DataLoaded event and in case it does not -- simply add it back to the collection.

All the best,
Rossen Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Boardy
Top achievements
Rank 1
Veteran
Answers by
Rossen Hristov
Telerik team
Boardy
Top achievements
Rank 1
Veteran
Share this question
or