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

How can set the LocalDataSourceProvider.ItemSource to DataTable?

6 Answers 264 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
lee
Top achievements
Rank 1
lee asked on 06 Nov 2012, 02:26 AM
How can set the ItemSource to DataTable, or have no plans to do so?

6 Answers, 1 is accepted

Sort by
0
Rosen Vladimirov
Telerik team
answered on 06 Nov 2012, 11:22 AM
Hi,

RadPivotGrid is supporting datatables. You can set the ItemsSource in the code behind:
LocalDataSourceProvider localDataProvider = this.Resources["DataSource"] as LocalDataSourceProvider;
localDataProvider.ItemsSource = _dataTable;
  
this.radPivotGrid.DataProvider = localDataProvider;
this.radPivotFieldList.DataProvider = localDataProvider;

Note that the "DataSource" is the x:Key of the LocalDataSourceProvider when it's defined in the XAML, _datatable is your DataTable, radPivotGrid and radPivotFieldList are the names of the two controls in the XAML.

Hopefully this helps.

All the best,
Rosen Vladimirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
lee
Top achievements
Rank 1
answered on 08 Nov 2012, 01:07 AM

*  following code does not work.What Am I wrong? Help Me.

DataSet dsData = this.Fill("SELECT stringcol1,stringcol2,doublecol FROM TestTable ");

localDataProvider = new LocalDataSourceProvider();

Telerik.Pivot.Core.PropertyGroupDescription propertyGroupDescription = new Telerik.Pivot.Core.PropertyGroupDescription();
propertyGroupDescription.PropertyName = "stringcol1";
localDataProvider.RowGroupDescriptions.Add(propertyGroupDescription);

Telerik.Pivot.Core.PropertyGroupDescription propertyGroupDescription2 = new Telerik.Pivot.Core.PropertyGroupDescription();
propertyGroupDescription2.PropertyName = "stringcol2";
localDataProvider.ColumnGroupDescriptions.Add(propertyGroupDescription2);

PropertyAggregateDescription propertyAggregateDescription1 = new PropertyAggregateDescription();
propertyAggregateDescription1.PropertyName = "doublecol ";
propertyAggregateDescription1.AggregateFunction = AggregateFunctions.Average;

localDataProvider.AggregateDescriptions.Add(propertyAggregateDescription1);

localDataProvider.ItemsSource = dsData.Tables[0];
this.radPivotGrid1.DataProvider = localDataProvider;

0
Rosen Vladimirov
Telerik team
answered on 08 Nov 2012, 02:32 PM
Hi,

I'm not sure exactly what you mean by saying that it is not working. Does it throw an exception or something else is happening?

Based on your code I made a simple project that is working, but I noticed one mistake in the code you've sent:
propertyAggregateDescription1.PropertyName = "doublecol ";

If your column is named "doublecol" than setting the PropertyName with this space symbol at the end will throw an exception. We have plans to make a better user interaction when such situation happens, but for now we you'll see only exception. Maybe this is causing your problems with the code below.

I'm sending you my test project. Hopefully it helps.

Regards,
Rosen Vladimirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
lee
Top achievements
Rank 1
answered on 09 Nov 2012, 07:45 AM
Thank you very much.
0
henley
Top achievements
Rank 1
answered on 17 Dec 2012, 03:25 AM
Hi,Rosen
I have to using MDX query result to bind RadPivotGrid,How to do?
0
Rosen Vladimirov
Telerik team
answered on 17 Dec 2012, 07:57 AM
Hello Henley,

It looks like you want to get data from OLAP cube. I suggest you to use our XmlaDataProvider or AdomdDataProvider. You are not able to use direct MDX query to populate RadPivotGrid with data, but the mentioned providers will give you access to the data in your cube.

Hopefully this helps.

Kind regards,
Rosen Vladimirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
PivotGrid
Asked by
lee
Top achievements
Rank 1
Answers by
Rosen Vladimirov
Telerik team
lee
Top achievements
Rank 1
henley
Top achievements
Rank 1
Share this question
or