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

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

1 Answer 85 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 20 Aug 2020, 07:20 PM

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.

1 Answer, 1 is accepted

Sort by
0
Attila Antal
Telerik team
answered on 25 Aug 2020, 03:25 PM

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).

Tags
PivotGrid
Asked by
David
Top achievements
Rank 1
Answers by
Attila Antal
Telerik team
Share this question
or