Rad Grid Export to Excel Problem

4 posts, 0 answers
  1. Arvind
    Arvind avatar
    40 posts
    Member since:
    Sep 2010

    Posted 11 Oct 2010 Link to this post

    Hi Telerik Team,

    I want to Export the Rad Grid data to the Excel Sheet, I have added a link button to the Rad Grid dynamically. For Exporting the Rad Grid data to the Excel Sheet i have placed the rad grid inside a "RadAjaxPanel", When i place the Rad grid Inside the RadAjaxPanel the entire data is being Exported to the Excel sheet, but the link button that i have added dynamically to the Rad grid is not doing any post back (My requirement is on clicking this link button it will get the DataKey and based on the DataKey value it will fetch the Records from the Database and display in the RadGrid in a POP-up), but when I remove the Rad Grid from the RadAjaxPanel the data is not being Exporting to the Excel Sheet it is giving the Following Error:

    "Server Error in '/' Application.

    Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation."

    In this Case the Link Button that i have added dynamically is doing the Post back and displaying the Data in the Pop-up.
    This is the Code that i am use for Rad Grid for opening pop-up on Link button Click:

    "<telerik:RadGrid ID="rgAccountDetails" runat="server" AllowPaging="True" PageSize="10" AllowFilteringByColumn="True" AllowSorting="True"  Visible="false"
                    Skin="Vista" OnPreRender="rgAccountDetails_PreRender" OnColumnCreated="rgAccountDetails_ColumnCreated" OnGridExporting="rgAccountDetails_GridExporting"
                    OnItemCommand="rgAccountDetails_ItemCommand" OnPageIndexChanged="rgAccountDetails_PageChanged"
                    OnExcelMLExportRowCreated="rgAccountDetails_ExcelMLExportRowCreated">
                    <ExportSettings ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true">
                    <Excel Format="ExcelML" />
                    <Pdf FontType="Subset" PaperSize="Letter" PageWidth="18in" PageHeight="150in" />
                </ExportSettings>
                        <PagerStyle Mode="NextPrevAndNumeric" />
                <MasterTableView  DataKeyNames="AccountID" CommandItemDisplay="Top">
                   <CommandItemSettings ShowExportToWordButton="true" ShowExportToExcelButton="true"
                    ShowExportToCsvButton="true" ShowAddNewRecordButton="false" ShowExportToPdfButton="True" />
                    <RowIndicatorColumn>
                        <HeaderStyle Width="20px" />
                    </RowIndicatorColumn>
                    <ExpandCollapseColumn>
                        <HeaderStyle Width="20px" />
                    </ExpandCollapseColumn>
                </MasterTableView>
            </telerik:RadGrid>"

    In the above code the link button is doing Post Back and fetching the data and display in the Pop-up, but Rad grid data is not exported to the Excel sheet.

    "<telerik:RadAjaxPanel ID="RadAjaxPanel2" runat="server" LoadingPanelID="RadAjaxLoadingPanel2" 
            ClientEvents-OnRequestStart="requestStart" HorizontalAlign="NotSet">
            <telerik:RadGrid ID="rgInvoicedetails" runat="server" AllowPaging="True" 
                    PageSize="7" AllowFilteringByColumn="True" AllowSorting="True"  Visible="False"
             Skin="Vista" OnItemCommand="rgInvoicedetails_ItemCommand" OnColumnCreated="rgInvoicedetails_ColumnCreated"
               OnPageIndexChanged="rgInvoicedetails_PageChanged" GridLines="None">
                     <PagerStyle Mode="NextPrevAndNumeric" />
                     <ExportSettings FileName="InvoiceReports" ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true">
                          <Excel Format="ExcelML" FileExtension="xlsx"  />
                    <Pdf FontType="Subset" PaperSize="Letter" PageWidth="18in" PageHeight="150in" />
                     </ExportSettings>
                <MasterTableView DataKeyNames="InvoiceID">
                    <CommandItemSettings ExportToPdfText="Export to Pdf" />
                    <RowIndicatorColumn>
                        <HeaderStyle Width="20px" />
                    </RowIndicatorColumn>
                    <ExpandCollapseColumn>
                        <HeaderStyle Width="20px" />
                    </ExpandCollapseColumn>
                </MasterTableView>
            </telerik:RadGrid>
            </telerik:RadAjaxPanel>"

    In the above code the link button is not doing Post Back and is not able fetching the data and display in the Pop-up, but the Grid data is Exported to the Excel Sheet.



    Please help me.

    Thanks,
    Arvind.
  2. Daniel
    Admin
    Daniel avatar
    4949 posts

    Posted 13 Oct 2010 Link to this post

    Hello Arvind,

    Please make sure that:

    - you are not exporting from an ajaxified control. If this is so, please examine the following link:
    Export from ajaxified grid

    - you are using advanced data-binding or datasource control.
    Advanced Data-binding

    Best regards,
    Daniel
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Sanjeev
    Sanjeev avatar
    4 posts
    Member since:
    Nov 2010

    Posted 04 Nov 2010 Link to this post

    Daniel,

    I am not able to even see these attributes in CommandItemSettings

    ShowExportToWordButton,
    ShowExportToExcelButton,
    ShowExportToCsvButton
    ShowAddNewRecordButton
    ShowExportToPdfButton

    I am using Telerik.Web.UI dll version 2009.

    Please suggest what is the problem ASAP.
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 04 Nov 2010 Link to this post

    Hello,

    With the latest internal build in 2009, RadGrid exposes the functionality to include export buttons to the default CommandItem. The GridCommandItemSettings class includes new Boolean properties that enable the respective GridTableView to show export buttons for the supported export types in its CommandItem.

    In your case, the problem is you are using older version of RadGrid and not able to access these properties. One suggestion is upgrading to latest version to use the feature.
    http://www.telerik.com/support/kb/aspnet-ajax/general/updating-radcontrols-for-asp-net-to-another-version-or-license.aspx


    In the case of you still want to use same version, it is possible to customize the GridCommandItem using "CommandItemTemplate".
    Command item template


    -Shinu.
Back to Top