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

PivotGrid export issue

1 Answer 53 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Jacek
Top achievements
Rank 1
Jacek asked on 27 Feb 2018, 04:37 PM

I am trying to export pivotgrid as an excel, but I used aggregate field with teplate label to show values in cells.

Excell export is using DataField as a value in cells. How can I use template label.text as a vaule for export instead of ID_TAB?

<telerik:PivotGridAggregateField CalculationExpression="" DataField="ID_TAB" GrandTotalAggregateFormatString="" UniqueName="column3">
    <TotalFormat Axis="Rows" Level="0" SortOrder="Ascending" TotalFunction="NoCalculation" />
    <CellTemplate>
        <asp:Label ID="Label2" runat="server" >                    
    </asp:Label>
    </CellTemplate>
</telerik:PivotGridAggregateField>

 

I believe it should be something similar to this:

protected void RadPivotGrid1_PivotGridCellExporting(object sender, PivotGridCellExportingArgs e)
{
    PivotGridBaseModelCell modelDataCell = e.PivotGridModelCell as PivotGridBaseModelCell;
    Label lblUSER_NM1 = e.PivotGridCell.FindControl("Label2") as Label;
    e.ExportedCell.Value = lblUSER_NM1.Text;
}

1 Answer, 1 is accepted

Sort by
0
Accepted
Eyup
Telerik team
answered on 02 Mar 2018, 04:42 PM
Hello Jacek,

Actually, you were pretty close:
protected void RadPivotGrid1_PivotGridCellExporting(object sender, PivotGridCellExportingArgs e)
{
    Label label = e.PivotGridCell.FindControl("Label2") as Label;
    if (label != null)
    {
        e.ExportedCell.Value = label.Text;
    }
}

Please give it a try and let me know if it works for you.

Regards,
Eyup
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
PivotGrid
Asked by
Jacek
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or