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

RadDataFilter twoway binding

6 Answers 50 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Igor
Top achievements
Rank 1
Igor asked on 27 May 2014, 06:13 PM
Hello All

How would I go about doing a bind to a viewmodel with RadDataFilter. The below does not work.

<telerik:RadDataFilter x:Name="JobsFilter" Source="{Binding Jobs}" FilteredSource="{Binding FilteredJobs, Mode=TwoWay, UpdateSourceTrigger=Explicit}" />

6 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 30 May 2014, 03:26 PM
Hi Igor,

Actually, RadDataFilter's FilteredSource property is a ReadOnly one, it has only a getter. You can get its value and return it through a property from your ViewModel, but you cannot bind it.

Regards,
Yoan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Scott
Top achievements
Rank 1
answered on 09 Mar 2015, 03:26 PM
Hi Yoan,
How would you go about getting the FilteredSource value from the viewmodel?  I'm trying to use RadDataFilter to filter resources in a ScheduleView control.  My resources are tied to a an appointment list.  Basically I was the user to be able to filter out which staff (resources) they want to see.  The only way I can think to do this is the bind to FilteredSource and update that list of resources, but that is all done in the viewmodel, not the view, so I can't bind anything to FilteredSource in XAML.
0
Scott
Top achievements
Rank 1
answered on 10 Mar 2015, 06:05 PM
I got this working for now, but to do so I broke the MVVM pattern.  Basically I'm listening for the event that fires when the FilterDescriptors change, and I pass in a reference to the View so I can access the DataFilter, then get its FilteredSource and use it accordingly.  I feel like there should be a better way that still adheres to MVVM.
0
Yoan
Telerik team
answered on 12 Mar 2015, 10:18 AM
Hi Scott,

You can check this forum post where a similar question has already been discussed. I believe you will find it useful for your scenario.

Regards,
Yoan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Scott
Top achievements
Rank 1
answered on 12 Mar 2015, 01:36 PM
You are correct, that is another way to accomplish what I'm doing, but it still breaks the MVVM pattern by subscribing to an event in the view's code.  My original question was how to do this in a MVVM-friendly way.  I don't know how I could reference the filteredsource in my viewmodel without breaking that pattern.  I'm having trouble binding a property in my VM to filteredsource since it is read only.
0
Dimitrina
Telerik team
answered on 12 Mar 2015, 05:13 PM
Hi,

A possible way to go and keep the MVVM pattern would to use an attached behavior. For more information on attached behaviors you can check the following blog post: MVVM via attached behaviors in Silverlight.

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
Igor
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Scott
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or