6 Answers, 1 is accepted
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.
* 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;
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.
I have to using MDX query result to bind RadPivotGrid,How to do?
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.