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

Setting data source provider in ViewModel

1 Answer 116 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Richard asked on 19 Jun 2014, 08:27 AM

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.

1 Answer, 1 is accepted

Sort by
Rosen Vladimirov
Telerik team
answered on 20 Jun 2014, 08:42 AM
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.
Asked by
Top achievements
Rank 1
Answers by
Rosen Vladimirov
Telerik team
Share this question