RadDataFilter twoway binding

7 posts, 0 answers
  1. Igor
    Igor avatar
    1 posts
    Member since:
    May 2014

    Posted 27 May 2014 Link to this post

    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}" />
  2. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 30 May 2014 Link to this post

    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.
     
  3. DevCraft banner
  4. Scott
    Scott avatar
    38 posts
    Member since:
    Sep 2012

    Posted 09 Mar 2015 in reply to Yoan Link to this post

    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.
  5. Scott
    Scott avatar
    38 posts
    Member since:
    Sep 2012

    Posted 10 Mar 2015 in reply to Scott Link to this post

    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.
  6. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 12 Mar 2015 Link to this post

    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.

     
  7. Scott
    Scott avatar
    38 posts
    Member since:
    Sep 2012

    Posted 12 Mar 2015 in reply to Yoan Link to this post

    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.
  8. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 12 Mar 2015 Link to this post

    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.

     
Back to Top
DevCraft banner