This is a migrated thread and some comments may be shown as answers.

[Solved] multiple grids on a page - why does only the 1st one export to PDF?

1 Answer 219 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kelly
Top achievements
Rank 1
Kelly asked on 30 Jun 2008, 01:56 PM
I have a TabStrip, and each tab has a RadGrid in it.  They all have the same PDF export settings and the same code (only the columns and data source are different).  But only the 1st grid works when I export to PDF.  Is this a known issue that I can't export from multiple grids on the same page? 

In the grids that don't work, when I click my Export To PDF button, the pager item and Export To PDF button disappears, and nothing happens.

Here is the code for one of the grids that doesn't export correctly - am I missing anything?  I also tried adding MasterTableView.ExportToPDF() but that didn't make a difference, and the first grid on my page works without it.

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ProgramAssignmentGrid.ascx.cs" 
    Inherits="Admin_UserControls_RepImport_ProgramAssignmentGrid" %> 
<%@ Register TagPrefix="telerik" Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" %> 
<asp:UpdatePanel runat="server">  
    <ContentTemplate> 
        <runat="server" id="pCaption">  
        </p> 
        <telerik:RadGrid ID="ProgramGrid" runat="server" BorderStyle="None" AllowSorting="true" 
            AutoGenerateColumns="false" EnableAJAX="True" EnableAJAXLoadingTemplate="true" 
            OnItemCommand="RadGrid1_ItemCommand">  
            <ExportSettings ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true">  
                <Pdf AllowAdd="false" AllowCopy="true" AllowModify="true" AllowPrinting="true" Author="Anonymous" 
                    Keywords="None" PageBottomMargin="1in" PageLeftMargin="1in" PageRightMargin="1in" 
                    PageTopMargin="1in" PageTitle="Rep Import - Program Assignments" Subject="Rep Import - Program Assignments" 
                    Title="Rep Import - Program Assignments" PaperSize="Letter" /> 
            </ExportSettings> 
            <MasterTableView AutoGenerateColumns="false" PagerStyle-AlwaysVisible="true" Width="100%">  
                <PagerTemplate> 
                    <asp:LinkButton ID="ExportToPdfButton" runat="server" CommandName="ExportToPdf">Export to PDF</asp:LinkButton> 
                </PagerTemplate> 
                <Columns> 
                    <telerik:GridBoundColumn HeaderText="Program" DataField="ProgramName" SortExpression="ProgramName">  
                        <HeaderStyle Width="50%" /> 
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn HeaderText="Territory" DataField="TerritoryName" SortExpression="TerritoryName">  
                        <HeaderStyle Width="45%" /> 
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn HeaderText="Budget" DataField="Budget" SortExpression="Budget">  
                        <HeaderStyle Width="10%" /> 
                    </telerik:GridBoundColumn> 
                </Columns> 
                <PagerStyle BorderStyle="None" Position="Top" /> 
            </MasterTableView> 
        </telerik:RadGrid> 
    </ContentTemplate> 
</asp:UpdatePanel> 
 

public partial class Admin_UserControls_RepImport_ProgramAssignmentGrid : MillenniumUserControl  
{  
    protected void Page_PreRender(object sender, EventArgs e)  
    {  
        Common.ApplyPdfExportStyles(ProgramGrid);  
    }  
    protected void Page_Load(object sender, EventArgs e)  
    {  
        ProgramGrid.Skin = Common.GridSkin;  
        ProgramGrid.AllowPaging = this.AllowPaging;  
        ProgramGrid.ExportSettings.Pdf.Title += (" " + DateTime.Now.ToShortDateString());  
    }  
 
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)  
    {  
        if (e.CommandName == RadGrid.ExportToPdfCommandName)  
        {  
            RepImport import = Session["RepImport"as RepImport;  
            if (import != null)  
            {  
                //add client name to page title  
                string clientName = Client.GetClientNameFromID(import.ClientID);  
                ProgramGrid.ExportSettings.FileName = "Rep Import Preview - Add Reps";  
                ProgramGrid.ExportSettings.Pdf.PageTitle  
                    = string.Format("Rep Import {0} - Add Reps for {1}",  
                                    DateTime.Now.ToShortDateString(),  
                                    clientName);  
            }  
        }  
    }  
 
    public RadGrid Grid  
    {  
        get { return ProgramGrid; }  
    }  
 
    public string Caption  
    {  
        get { return pCaption.InnerText; }  
        set { pCaption.InnerText = value; }  
    }  
 
    public bool AllowPaging  
    {  
        get { return allowPaging; }  
        set { allowPaging = value; }  
    }  
    private bool allowPaging = true;  
}  
 

1 Answer, 1 is accepted

Sort by
0
Kelly
Top achievements
Rank 1
answered on 30 Jun 2008, 02:32 PM
Never mind, I found out why the other grids weren't working. I was missing the "AjaxSettings" code for the other grids:

<

telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="___">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="___" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
<ClientEvents OnRequestStart="OnRequestStart" /> 
</telerik:RadAjaxManager>.



Tags
Grid
Asked by
Kelly
Top achievements
Rank 1
Answers by
Kelly
Top achievements
Rank 1
Share this question
or