Custom export/print buttons not working

2 posts, 0 answers
  1. Benjamin
    Benjamin avatar
    3 posts
    Member since:
    May 2018

    Posted 29 Jun 2018 Link to this post

    I can't use the built-in command items and have defined my own command item template.  However, all that happens when I click export or print is the command item header, footer, and paging disappear.  I do not get a excel or pdf file.  Here is my code.  What should I do different?  Thanks!

     

    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" EnableAJAX="true">
                    <telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" GridLines="None" onitemdatabound="RadGrid1_OnItemDataBound" OnItemCommand="RadGrid1_OnItemCommand" AllowFilteringByColumn="true" runat="server" FilterType="HeaderContext" EnableHeaderContextMenu="true" skin="Bootstrap"
                         EnableHeaderContextFilterMenu="true" AllowPaging="True" PagerStyle-AlwaysVisible="true" OnFilterCheckListItemsRequested="RadGrid1_FilterCheckListItemsRequested" AllowSorting="true" GroupingEnabled="true" >
                        <ExportSettings FileName="Inventory" IgnorePaging="True" SuppressColumnDataFormatStrings="True" ExportOnlyData="True" OpenInNewWindow="True">
                            <Excel Format="Xlsx" />
                        </ExportSettings>
                        <MasterTableView AutoGenerateColumns="False" DataKeyNames="InventoryId" CommandItemDisplay="TopAndBottom">
                            <CommandItemTemplate>
                                <div class="right">
                                    <asp:ImageButton runat="server" id="btnNew" ImageUrl="/images/icons/add.png" tooltip="Add New Inventory" alternateText="Add New Inventory" commandName="New"/>
                                    <asp:ImageButton runat="server" id="btnPrint" ImageUrl="/images/icons/print.png" tooltip="Print" alternateText="Print" commandName="Print"/>
                                    <asp:ImageButton runat="server" id="btnExport" ImageUrl="/images/icons/save.png" tooltip="Export to Excel" alternateText="Export to Excel" commandName="Export"/>
                                </div>
                            </CommandItemTemplate>
                            <Columns>
                                <telerik:GridBoundColumn FilterCheckListEnableLoadOnDemand="true" DataField="InventoryName" FilterControlAltText="Filter Inventory Name column" HeaderText="Name" SortExpression="InventoryName" UniqueName="InventoryName"/>
                                <telerik:GridBoundColumn display="False" FilterCheckListEnableLoadOnDemand="true" DataField="InventoryDescription" FilterControlAltText="Filter Inventory Description column" HeaderText="Description" SortExpression="InventoryDescription" UniqueName="InventoryDescription"/>
                                <telerik:GridBoundColumn ReadOnly="True" FilterCheckListEnableLoadOnDemand="true" DataField="BuildingName" FilterControlAltText="Filter Building Name column" HeaderText="Building" SortExpression="BuildingName" UniqueName="BuildingName"/>
                                <telerik:GridBoundColumn ReadOnly="True" FilterCheckListEnableLoadOnDemand="true" DataField="SpaceName" FilterControlAltText="Filter Space Name column" HeaderText="Space" SortExpression="SpaceName" UniqueName="SpaceName"/>
                                <telerik:GridBoundColumn ReadOnly="True" FilterCheckListEnableLoadOnDemand="true" DataField="InventoryTypeName" FilterControlAltText="Filter Inventory Type column" HeaderText="Type" SortExpression="InventoryTypeName" UniqueName="InventoryTypeName"/>
                                <telerik:GridBoundColumn ReadOnly="True" FilterCheckListEnableLoadOnDemand="true" DataField="CategoryName" FilterControlAltText="Filter Inventory Category column" HeaderText="Category" SortExpression="CategoryName" UniqueName="CategoryName"/>
                                <telerik:GridBoundColumn ReadOnly="True" display="False" FilterCheckListEnableLoadOnDemand="true" DataField="UnitQuantityAbbreviation" FilterControlAltText="Filter Unit Abbreviation" HeaderText="Unit" SortExpression="UnitQuantityAbbreviation" UniqueName="UnitQuantityAbbreviation"/>
                                <telerik:GridBoundColumn display="False" FilterCheckListEnableLoadOnDemand="true" DataField="UnitPrice" DataFormatString="{0:C}" FilterControlAltText="Filter Unit Price" HeaderText="Price" SortExpression="UnitPrice" UniqueName="UnitPrice"/>
                                <telerik:GridBoundColumn FilterCheckListEnableLoadOnDemand="true" DataField="CurrentQuantity" FilterControlAltText="Filter Current Quantity" HeaderText="Quantity" SortExpression="CurrentQuantity" UniqueName="CurrentQuantity"/>
                                <telerik:GridBoundColumn display="False" FilterCheckListEnableLoadOnDemand="true" DataField="MinimumQuantity" FilterControlAltText="Filter Minimum Quantity" HeaderText="Minimum" SortExpression="MinimumQuantity" UniqueName="MinimumQuantity"/>
                                <telerik:GridBoundColumn display="False" FilterCheckListEnableLoadOnDemand="true" DataField="PartNumber" FilterControlAltText="Filter Part Number" HeaderText="Part" SortExpression="PartNumber" UniqueName="PartNumber"/>
                                <telerik:GridBoundColumn display="False" FilterCheckListEnableLoadOnDemand="true" DataField="ModelNumber" FilterControlAltText="Filter Model Number" HeaderText="Model" SortExpression="ModelNumber" UniqueName="ModelNumber"/>
                                <telerik:GridBoundColumn display="False" FilterCheckListEnableLoadOnDemand="true" DataField="StockNumber" FilterControlAltText="Filter Stock Number" HeaderText="Stock" SortExpression="StockNumber" UniqueName="StockNumber"/>
                                <telerik:GridBoundColumn display="False" FilterCheckListEnableLoadOnDemand="true" DataField="Manufacturer" FilterControlAltText="Filter Manufacturer" HeaderText="Mfr." SortExpression="Manufacturer" UniqueName="Manufacturer"/>
                                <telerik:GridBoundColumn display="False" FilterCheckListEnableLoadOnDemand="true" DataField="Url" FilterControlAltText="Filter Url" HeaderText="Url" SortExpression="Url" UniqueName="Url"/>
                                 
                                <telerik:GridButtonColumn ConfirmText="Delete this inventory?" ConfirmDialogType="RadWindow" EnableHeaderContextMenu="False" ConfirmTitle="Delete" Exportable="False" Reorderable="False" ButtonType="ImageButton" ImageUrl="/images/icons/delete.png" ColumnGroupName="Action" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                                    <HeaderStyle CssClass="rgHeader ButtonColumnHeader"></HeaderStyle>
                                    <ItemStyle CssClass="ButtonColumn" />
                                </telerik:GridButtonColumn>
                                <telerik:GridButtonColumn Text="Edit" CommandName="Edit" Exportable="False" Reorderable="False" EnableHeaderContextMenu="False" FilterCheckListEnableLoadOnDemand="False"  ButtonType="ImageButton" ImageUrl="/images/icons/edit.png" ColumnGroupName="Action"/>
                            </Columns>
                        </MasterTableView>
                    </telerik:RadGrid>
                </telerik:RadAjaxPanel>

     

     

    Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
            RadGrid1.DataSource = InventoryController.GetInventoriesForList()
        End Sub
     
        Protected Sub RadGrid1_OnItemCommand(sender As Object, e As GridCommandEventArgs)
            Select Case e.CommandName
                Case "New"
                    Response.Redirect("InventoryManage.aspx")
                Case "Edit"
                    Response.Redirect(String.Format("InventoryManage.aspx?id={0}", GetInventoryIdFromGridItem(e.Item)))
                Case "Delete"
                    InventoryController.DeleteInventory(GetInventoryIdFromGridItem(e.Item))
                Case "Print"
                    RadGrid1.MasterTableView.ExportToPdf()
                Case "Export"
                    RadGrid1.MasterTableView.ExportToExcel()
            End Select
        End Sub

     

  2. Eyup
    Admin
    Eyup avatar
    3756 posts

    Posted 04 Jul 2018 Link to this post

    Hi,

    You can resolve this issue by disabling AJAX when exporting:
    https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/how-to/Exporting/export-from-ajaxified-grid

    I hope this will prove helpful.

    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