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

radgrid Export to PDF commanditem and ajax

3 Answers 118 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 03 Nov 2010, 09:51 PM

I have a following code in my radgrid:

<CommandItemTemplate>
    <asp:LinkButton ID="ExportToPdfButton" runat="server" CommandName="ExportToPdf" CssClass="pdfButton" ></asp:LinkButton>
</CommandItemTemplate>

The radgrid is ajaxafied with a RadAjaxManager.

Use ItemCreated in I call RegisterPostBackControl so that when I click the PDF button it doesn't use ajax and pops up my PDF.

Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated
        If TypeOf e.Item Is GridCommandItem Then
            Dim btn As LinkButton = e.Item.FindControl("ExportToPdfButton")
            If Not btn Is Nothing Then
                RadScriptManager.GetCurrent(Page).RegisterPostBackControl(btn)
            End If
        End If
End Sub

This works fine the first time my page loads. I click the PDF, it opens up... all good. 
However, I have a series of combo boxes that are wired in the RadAjaxManager to rebind the grid when changed. When the radgrid gets changed through an ajax postback, and I click the PDF button, it then causes an ajax postback and the commanditem template disappears entirely, and of course.. the PDF is not created.

Any idea how I can make sure the PDF button always does a regular postback?

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 03 Nov 2010, 10:47 PM
Hello Greg,

I suggest that you avoid the RegisterPostBackControl workaround since it won't work in some scenarios. Instead, I recommend that you use the approach depicted in the following link:
Export from ajaxified grid

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
0
Greg
Top achievements
Rank 1
answered on 03 Nov 2010, 11:09 PM
Thanks. However, it now pops the PDF, but still starts the loading panels which show my "Loading..." image... but never complete.

So when I close or cancel the pdf, I can't see my grid anymore and have to refresh the page, or trigger an ajax postback with one of my combo boxes to get it to reappear.
0
Greg
Top achievements
Rank 1
answered on 03 Nov 2010, 11:36 PM
Nevermind... had my radajaxmanager improperly setup...
Tags
Grid
Asked by
Greg
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Greg
Top achievements
Rank 1
Share this question
or