PivotGrid export issue

2 posts, 1 answers
  1. Jacek
    Jacek avatar
    18 posts
    Member since:
    Apr 2011

    Posted 27 Feb 2018 Link to this post

    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;
    }
  2. Answer
    Eyup
    Admin
    Eyup avatar
    3785 posts

    Posted 02 Mar 2018 Link to this post

    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.
Back to Top