Setting data source provider in ViewModel

2 posts, 1 answers
  1. Richard
    Richard avatar
    14 posts
    Member since:
    Aug 2011

    Posted 19 Jun 2014 Link to this post


    Seems that all posts that are remotely related to what I am experiencing are close to or more than a year old.

    Once again I have the issue with the Telerik help that all code and samples are for static data sets and I find it really difficult to get samples of code that actually work in an MVVM environment.  Point in case, according to the Telerik PivotGrid help, the following code is supposed to define rows for a localdataprovider:

    Telerik.Pivot.Core.PropertyGroupDescription propertyGroupDescription = new Telerik.Pivot.Core.PropertyGroupDescription();
                    propertyGroupDescription.PropertyName = "Name";
                    DateTimeGroupDescription dateTimeGroupDescription = new DateTimeGroupDescription();
                    dateTimeGroupDescription.PropertyName = "Date";
                    dateTimeGroupDescription.Step = DateTimeStep.Month;

                    using (localDataProvider.DeferRefresh())

    However as soon as I set the ItemsSource property to my actual collection of data, then the RowGroupDescriptions and ColumnGroupDescriptions collections are set to 0 and then nothing shows in the control.

    Same if I set the ItemsSource before defining the groups, then the PropertyGroupDescriptions don't even get added to the collections.

    I can't find any help on this scenario so I have posted here.

  2. Answer
    Rosen Vladimirov
    Rosen Vladimirov avatar
    640 posts

    Posted 20 Jun 2014 Link to this post

    Hi Richard,

    I've prepared a sample project to demonstrate how you can define and use LocalDataSourceProvider in your ViewModel. Please note that if you add GroupDescription and you set the PropertyName to a value that doesn't exist in your DataItem, the group description will not be created. For example - if you have collection of Orders and each Order have the following properties: "Net", "Quantity", "Product", when you try adding a new PropertyGroupDescrtiption with PropertyName="Advertisement", RadPivotGrid will not create it as there's no property "Advertisement" in Order class.

    Could you test the attached project and inform us if it works for you? I'm looking forward to hearing from you.

    Rosen Vladimirov
    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 R3 2016 release webinar banner
Back to Top