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

[Solved] SortDescriptors and FilterDescriptors Bindability

2 Answers 116 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jeff
Top achievements
Rank 1
Jeff asked on 17 Nov 2010, 04:23 PM

Hi all, it's been a while since I posted on here but hopefully these suggestions will help someone else. They are not any major issues, just trying to make the controls easier to bind against.

I was wondering if it'd be possible to expose the set accessor for the SortDescriptors property on the RadGridView control. I was tasked recently with connecting the sorting of the control to requery the data from the RIA data source (which I got working) and this was one of the parts that could have been a bit easier to work with.

 

((ViewModelLocator)this.Resources["vml"]).MyViewModel.SortFields = radGridView1.SortDescriptors;

 

 

Granted all that was need was writing that single line of code in the code behind for the xaml page, but that wouldn't be necessary if the set accessor was available.

Also, the same thing could be said for the FilterDescriptors property on the RadDataFilter control. I had to connect this control to use RIA to change the where clause on the query that was filling the RadGridView. Without the set accessor being exposed, trying to bind to the collection INotifyPropertyChanged event from the base ObservableCollection from the CompoositeFilterDescriptorsCollection will cause you to miss the outermost and/or operator that's on the collection. So it was a requirement to use the same instance of the collection that the control was using.

((ViewModelLocator)this.Resources["vml"]).MyViewModel.Filters = dataFilter.FilterDescriptors;

Placing that line of code in the code behind fixes the issue, but it shouldn't need to be there. The view models need access to the same collection the controls use to ensure the interface gets updated if any are programmatically added or removed.

Just a couple suggestions I had working with the controls recently. Other than these couple relatively minor issues everything worked perfectly!

- Jeff

2 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 17 Nov 2010, 04:31 PM
Hello Jeff,

 You can use the approach in this blog post to synchronize the descriptors between your ViewModel and RadGridView.

Sincerely yours,
Yavor Georgiev
the Telerik team
See What's New in RadControls for Silverlight in Q3 2010 on Tuesday, November 16, 2010 11:00 AM - 12:00 PM EST or 10:00 PM - 11:00 PM EST: Register here>>
0
Jeff
Top achievements
Rank 1
answered on 17 Nov 2010, 04:37 PM
That approach may work for the sort filters, but the filters on the RadDataFilter must have the instance used by the control as I indicated in my post. Not sure why I bothered writing all that, it's obvious it wasn't read.

Not to mention you want me to write 40 lbs of code to bind to a property that the set accessor that wasn't exposed.

Edit: I'd like to mention we tried that approach originally.
Tags
GridView
Asked by
Jeff
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Jeff
Top achievements
Rank 1
Share this question
or