How can set the LocalDataSourceProvider.ItemSource to DataTable?

7 posts, 0 answers
  1. lee
    lee avatar
    14 posts
    Member since:
    Nov 2010

    Posted 05 Nov 2012 Link to this post

    How can set the ItemSource to DataTable, or have no plans to do so?
  2. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 06 Nov 2012 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. lee
    lee avatar
    14 posts
    Member since:
    Nov 2010

    Posted 07 Nov 2012 Link to this post

    *  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;

  5. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 08 Nov 2012 Link to this post

    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.

  6. lee
    lee avatar
    14 posts
    Member since:
    Nov 2010

    Posted 09 Nov 2012 Link to this post

    Thank you very much.
  7. henley
    henley avatar
    14 posts
    Member since:
    Nov 2012

    Posted 16 Dec 2012 Link to this post

    Hi,Rosen
    I have to using MDX query result to bind RadPivotGrid,How to do?
  8. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 17 Dec 2012 Link to this post

    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.

Back to Top
UI for WPF is Visual Studio 2017 Ready