Exporting Two Individual Grids in a Single PDF

3 posts, 0 answers
  1. Vivek
    Vivek avatar
    38 posts
    Member since:
    Mar 2013

    Posted 17 May 2013 Link to this post

    Hi,

    We have used two individual grids to display data which looks like single grid on the page but behind the scene, these are two individual grids. Now the problem is, we want to export the entire data displayed in the UI but we can only export one grid at a time.

    Is there any way, we can pass two grids as an input to the ExportToPdf() function to export at the same time in the same file?

    Waiting for your earliest reply on this.
  2. Vivek
    Vivek avatar
    38 posts
    Member since:
    Mar 2013

    Posted 20 May 2013 Link to this post

    Still hoping resolution on this, please let me know if implementation of this scenario is possible.?
  3. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 20 May 2013 Link to this post

    Hi,
    Try the following code snippet.
    ASPX:

    <telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="false">
      <Items>
        <telerik:RadComboBoxItem Text="RadGrid1" />
        <telerik:RadComboBoxItem Text="RadGrid2" />
        <telerik:RadComboBoxItem Text="RadGrid3" />
        <telerik:RadComboBoxItem Text="All RadGrids" />
      </Items>
    </telerik:RadComboBox>
    <asp:Button ID="btn" runat="server" Text="click" OnClick="btn_Click" />
     
    <telerik:RadGrid ID="RadGridWrapper" runat="server" ShowHeader="false" Width="550px" BorderStyle="None" OnItemCreated="RadGridWrapper_ItemCreated">
     <ExportSettings OpenInNewWindow="true" />
     <MasterTableView AutoGenerateColumns="true" BorderStyle="None">
      <ItemTemplate>
      <telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid_NeedDataSource" BorderStyle="None" Skin="Office2007">
       <ExportSettings ExportOnlyData="true" OpenInNewWindow="true" />
       <MasterTableView AutoGenerateColumns="false">
          <Columns>
            ... ... ...
          </Columns>
       </MasterTableView>
      </telerik:RadGrid>
       <br />
      <telerik:RadGrid ID="RadGrid2" runat="server" OnNeedDataSource="RadGrid_NeedDataSource"  BorderStyle="None">
       <ExportSettings ExportOnlyData="true" OpenInNewWindow="true" />
       <MasterTableView AutoGenerateColumns="false">
          <Columns>
           ... ... ...
          </Columns>
       </MasterTableView>
      </telerik:RadGrid>
     </ItemTemplate>
    </MasterTableView>
    </telerik:RadGrid>
    C#:
    protected void RadGridWrapper_ItemCreated(object sender, GridItemEventArgs e)
       {
        if (e.Item is GridHeaderItem)
            e.Item.Visible = false;
       }
     
       protected void RadGrid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            DataTable table = new DataTable();
              //RadGrid binding
            (source as RadGrid).DataSource = table;
        }
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            RadGrid radGrid = RadComboBox1.SelectedItem.Text == "All RadGrids" ? RadGridWrapper : (RadGrid)RadGridWrapper.Items[0].FindControl(RadComboBox1.SelectedItem.Text);
            radGrid.MasterTableView.ExportToPdf();
        }

    Please have a look into the following code library.
    Export multiple RadGrids in single PDF/Excel file

    Thanks,
    Princy.
Back to Top