add multiple radgrids dynamically to a wrapper radgrid and export to PDF

3 posts, 0 answers
  1. libni
    libni avatar
    2 posts
    Member since:
    Mar 2019

    Posted 26 Mar 2019 Link to this post

    I want to export 2 RadGrids to PDF,using the RadGrid's inbuilt exporting feature. I have a wrapper Grid. The Grids that I want to export are located at different parets of my UI, so I don't want to add the grids directly in the wrapper grid. On the Export button click, I want to add the Gridsto the Wrapper grid and export to PDF.  I just want both grids to be on a single PDF file. Alternatively it's okay for me convert the first child grid(data filter details) to a string of text, with new lines, and place on the top of the PDF export of the second (bigger data grid), for this also I couldn't find a way. I have a sample code, but since I am new to the forum, I couldn't find an easy way to copy it here. I will do it as soon as I can. Thanks in advance.
  2. libni
    libni avatar
    2 posts
    Member since:
    Mar 2019

    Posted 26 Mar 2019 in reply to libni Link to this post

    <form runat="server">
        <asp:ScriptManager ID="sm" runat="server"></asp:ScriptManager>
        <telerik:RadButton ID="btnExportToPDF" runat="server" Text="Export To PDF" OnClick="btnExportToPDF_Click"></telerik:RadButton>
     
        <telerik:RadGrid ID="grdEmployees" runat="server" OnNeedDataSource="grdEmployees_NeedDataSource">
            <MasterTableView AutoGenerateColumns="true">
            </MasterTableView>
        </telerik:RadGrid>
        <telerik:RadGrid ID="grdDepartments" runat="server" OnNeedDataSource="grdDepartments_NeedDataSource">
            <MasterTableView AutoGenerateColumns="true">
            </MasterTableView>
        </telerik:RadGrid>
     
     
        <telerik:RadGrid ID="grdMyWrapper" runat="server" ShowHeader="false" Width="550px" BorderStyle="None" OnItemCreated="RadGridWrapper_ItemCreated" Visible="true">
            <ExportSettings OpenInNewWindow="true" ExportOnlyData="false" />
            <MasterTableView AutoGenerateColumns="true" BorderStyle="None">
                <ItemTemplate>
                </ItemTemplate>
            </MasterTableView>
        </telerik:RadGrid>
    </form>

     

    protected void RadGridWrapper_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridHeaderItem) e.Item.Visible = false;
    }
     
    protected void btnExportToPDF_Click(object sender, EventArgs e)
    {
        grdMyWrapper.Items[0].Cells[0].Controls.Add(grdEmployees);
        grdMyWrapper.Items[0].Cells[0].Controls.Add(grdDepartments);
         grdMyWrapper.ExportToPdf();
    }

     

    Even alternative ways to achieve would be a great help. Thanks.

  3. Attila Antal
    Admin
    Attila Antal avatar
    609 posts

    Posted 29 Mar 2019 Link to this post

    Hi Libni,

    We have a code-library sample which I would recommend for this scenario. That sample shows the way to export multiple Grids to PDF and even for Excel at Export multiple RadGrids in single PDF/Excel file. Please check it out and see if that works for you.

    For more details about the PDF Export functionality, you can check out the PDF Export article, and also the Questions and Answers section of it.

    Kind regards,
    Attila Antal
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top