Unplanned
Last Updated: 03 Jan 2022 12:25 by ADMIN
Rolf Falnes
Created on: 03 Jan 2022 11:47
Category: Grid
Type: Bug Report
0
GenerateExportOutput() method changes the Grid structure
We're having problems using GenerateXlsxOutput and ExportSettings.IgnorePaging.
When ExportSettings.IgnorePaging is true the grid's paging disappears after exporting.

We're using Asp.Net Ajax version 2021.3.1111.45.
1 comment
ADMIN
Attila Antal
Posted on: 03 Jan 2022 12:25

Hi Rolf,

Thank you for reporting this problem. 

We have managed to replicate the issue by calling the GenerateExportOutput() method in a Button click while IgnorePaging is enabled.

Workaround

The current workaround we can suggest is to use the Grid's ItemCommand event when calling this method.

C#

protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    var grid = (RadGrid)sender;

    if(e.CommandName == RadGrid.ExportToExcelCommandName)
    {
        var exportOutput = grid.MasterTableView.GenerateXlsxOutput<xlsx.Workbook>() as xlsx.Workbook;

        // Do something with output here.
    }
}

 

VB

Protected Sub RadGrid1_ItemCommand(ByVal sender As Object, ByVal e As GridCommandEventArgs)
    Dim grid = CType(sender, RadGrid)

    If e.CommandName = RadGrid.ExportToExcelCommandName Then
        Dim exportOutput = TryCast(grid.MasterTableView.GenerateXlsxOutput(Of xlsx.Workbook)(), xlsx.Workbook)
        ' Do something with output here.
    End If
End Sub

 

The ItemCommand event will trigger when using the Built-in Export Button of the Grid

<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" OnItemCommand="RadGrid1_ItemCommand">
    <ExportSettings ExportOnlyData="true" IgnorePaging="true">
        <Excel Format="Xlsx" />
    </ExportSettings>
    <MasterTableView CommandItemDisplay="Top">
        <CommandItemSettings ShowExportToExcelButton="true" />
    </MasterTableView>
</telerik:RadGrid>

 

Or if you fired the Command Event using the FireCommandEvent() method from an external button

C#

protected void RadButton1_Click(object sender, EventArgs e)
{
    GridItem myGridItem = null;

    if (RadGrid1.ShowHeader)
        myGridItem = RadGrid1.MasterTableView.GetItems(GridItemType.Header).FirstOrDefault();
    else if (RadGrid1.MasterTableView.CommandItemDisplay != GridCommandItemDisplay.None)
        myGridItem = RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem).FirstOrDefault();
    else if (RadGrid1.ShowFooter)
        myGridItem = RadGrid1.MasterTableView.GetItems(GridItemType.Footer).FirstOrDefault();
    else if (RadGrid1.Items.Count > 0)
        myGridItem = RadGrid1.Items[0];

    if (myGridItem != null)
        myGridItem.FireCommandEvent("ExportToExcel", "");
}

 

VB

Protected Sub RadButton1_Click(ByVal sender As Object, ByVal e As EventArgs)
    Dim myGridItem As GridItem = Nothing

    If RadGrid1.ShowHeader Then
        myGridItem = RadGrid1.MasterTableView.GetItems(GridItemType.Header).FirstOrDefault()
    ElseIf RadGrid1.MasterTableView.CommandItemDisplay <> GridCommandItemDisplay.None Then
        myGridItem = RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem).FirstOrDefault()
    ElseIf RadGrid1.ShowFooter Then
        myGridItem = RadGrid1.MasterTableView.GetItems(GridItemType.Footer).FirstOrDefault()
    ElseIf RadGrid1.Items.Count > 0 Then
        myGridItem = RadGrid1.Items(0)
    End If

    If myGridItem IsNot Nothing Then myGridItem.FireCommandEvent("ExportToExcel", "")
End Sub

 

Until the issue is fixed, please use this workaround.

 

Regards,
Attila Antal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.