Will the same technique work if I should decide to switch from the MS datagrid to RadGridView?
20 Answers, 1 is accepted
Unfortunately no. RadGridView for WPF sniffs sort and group descriptions from the collection view it is bound to, and that will work for Silverlight too. We lack the reverse link though -- the grid will not add a sort or group description back to the original collection view.
Currently the recommended way to do custom sorting is via our SortingRequested event. We were discussing internally about improving our collection view sort/group/filter support, and we will be researching possible ways to do that in the future.
All the best,
Hristo Deshev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Oops! Forgot the link to the WPF example. Anyway, it uses an ADO.NET DataView and its built-in sorting capabilities and it is not a very good example for a Silverlight component.
To make amends, I have been playing with the dynamic LINQ query library and I've created a custom sorting example that uses the info passed through the SortingRequested event to sort the original data source. I am attaching the sample project.
All the best,
Hristo Deshev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Can you please provide code snippet for this.
Prompt reply would be appreciated.
You can use our powerful converter to convert desired C# code to VB. VB version of Dynamic LINQ can be found here: http://msdn.microsoft.com/en-us/bb964686.aspx.
Best wishes,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Hi John Carr,
RadGridView now has two events that are related to sorting - the first one is called Sorting (almost identical to SortingRequested) and it is fired just before the grid is sorted; the seconds one is called Sorted and it is fired after the sorting is completed.
In case you would like to cancel a sorting request you just have to set the Canel property to true :
void gridView_Sorting(object sender, GridViewSortingEventArgs e) |
{ |
e.Cancel = true; |
} |
Kind regards,
Milanthe Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I have 2 issues related to sorting on the Silverlight gridview that I'm trying to work through and would appreciate any help.
1. We do sorting on the server so I want to cancel the sorting event, exactly as your example shows however the grid still sorts
2. I am setting the sortDescriptors to the correct column and direction then adding that to the grid, but the icon never appears in the header of the column. I looked at the examples in the controls demo, and I'm following that example as accurately as possible. Am I missing a property setting?
Any help will be greatly appreciated.
Ps: I'm adding the columns to the grid dynamically at runtime.
Running the latest 2009 Q2 Sp1
When you are using custom sorting you should not add items to the SortDescriptors collection because that triggers the built-in sorting. Your code should look something like that:
void gridView_Sorting(object sender, GridViewSortingEventArgs e) |
{ |
if (e.SortingState == SortingState.None) |
{ |
e.SortingState = SortingState.Ascending; |
this.gridView.ItemsSource = this.GetSortedData(e.SortPropertyName, "ASC"); |
} |
else if (e.SortingState == SortingState.Ascending) |
{ |
e.SortingState = SortingState.Descending; |
this.gridView.ItemsSource = this.GetSortedData(e.SortPropertyName, "DESC"); |
} |
else |
{ |
this.gridView.ItemsSource = this.GetData(); |
e.SortingState = SortingState.None; |
} |
e.Cancel = true; |
} |
Sincerely yours,
Milan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Generally simple CollectionView is a bit limited if you want to store RadGridView settings like grouping and filtering. Why not use QueryableCollectionView instead CollectionView?
Best wishes,Vlad
the Telerik team
Is there a way to get the RadGridView to update the Filter property in a Two-Way manner?
I'm not sure how QueryableCollectionView limits you since the collection is not generic. Can you explain?
The grid filtering is complex hierarchical structure however ICollectionView Filter is just a predicate.
Vlad
the Telerik team
I'm just wondering if this has changed yet?
i.e. Does the RadGridView automatically add to the ICollectionView's SortDescriptionCollection collection?
Or is this something I have to do manually with events?
As I've noticed it does tie in with the DomainDataSource, but I can not seem to get it to tie in with my custom collection (But I'm using a derived class of the SortDescriptionCollection
i.e.:
#region ICollectionView Members
private
CustomSortDescriptionCollection sortDescriptions =
new
CustomSortDescriptionCollection();
public
SortDescriptionCollection SortDescriptions {
get
{
return
sortDescriptions; } }
(The only thing my CustomSortDesciption really does is exposes new PUBLIC CollectionChanged notification, and bubbles the base sortdescriptioncollection's changes)
*edit*
I tried swapping my private backing field with just a regular sort desc collection
I've noticed the Grid view is "get"ing the sort descriptions, but it is still not adding to them
Would it be possible for you to open a support ticket and send us your application so that we may debug this behavior, please?
Kind regards,
Yavor Georgiev
the Telerik team
When the GridView's ItemsSource implements ICollectionView, the GridView should manipulate its source's SortDescriptions collection as the user performs sorting. That is to say, it should all be automatic. There must be a problem somewhere for this not to work, thus we need to debug your application to discover the cause of this problem and fix it.
Kind regards,
Yavor Georgiev
the Telerik team
358430
(The project will demonstrate the sort descriptors not working as mentioned in this post, and my placeholder problem in my other post)
Please check out my response to your question in the private support thread.
Kind regards,
Yavor Georgiev
the Telerik team