Get Resulting pivotgrid data into a new datatable to feed a chart

2 posts, 0 answers
  1. David
    David avatar
    1 posts
    Member since:
    Apr 2012

    Posted 20 Aug 2020 Link to this post

    Hello,

     

    After a user configures their Pivotgrid to show the data the way they like it, I would like to get the resulting data into a data table for other uses like generating a chart off of the the resulting data.   It would be like the excel export function but export to a datatable in code behind.

  2. Attila Antal
    Admin
    Attila Antal avatar
    609 posts

    Posted 25 Aug 2020 Link to this post

    Hi David,

    That is an interesting scenario. We haven't done this before, but it may be implemented. You can try to loop through the items, fields and build a structure of data table of your choice.

    Here are a few examples of the server-side API to loop through different items

    protected void RadButton1_Click(object sender, EventArgs e)
    {
        foreach (var colField in RadPivotGrid1.Fields.OfType<PivotGridColumnField>())
        {
            var colFieldName = colField.UniqueName;
        }
    
        foreach (var rowField in RadPivotGrid1.Fields.OfType<PivotGridRowField>())
        {
            var rowFieldName = rowField.UniqueName;
        }
    
        foreach (var rowHeaderItem in RadPivotGrid1.Items.OfType<PivotGridRowHeaderItem>())
        {
            foreach (PivotGridHeaderCell headerCell in rowHeaderItem.Cells)
            {
                var headerCellText = headerCell.Text;
            }
        }
    
        foreach (var rowItem in RadPivotGrid1.Items.OfType<PivotGridRowItem>())
        {
            foreach (PivotGridDataCell dataCell in rowItem.Cells)
            {
                var dataCellText = dataCell.Text;
            }
        }
    }

     

    Regards,
    Attila Antal
    Progress Telerik

    Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

Back to Top