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

RadGrid Export to PDF with master page

5 Answers 250 Views
Grid
This is a migrated thread and some comments may be shown as answers.
DANA
Top achievements
Rank 1
Veteran
DANA asked on 15 May 2012, 08:00 AM
I tried to use the export to PDF for the Telerik RadGrid but it doesn't work.
I think that this is a problem for me since all of my pages are inside Master page that already has script manager, so I can't add another one in my content page.
What can I do to solve it?

right now, I have this:

masterpage:
<asp:ScriptManager id="scriptmanager1" runat="server"/>

contentpage:
<asp:content id="content1" contentplaceholder="contentplaceholder1" runat="server">
<asp:updatepanel id="up1" runat="sever"
<telerik:RadGrid id="radgrid1"...>
<exportSetting ignorePaging="true" openInNewWindow="true">
<pdf pageheight="297mm" pagewidth="210mm" 
</exportSetting>
<masterTableView commanditemdisplay="top">
<command itemtemplate>
<asp:imagebutton id="downloadpdf" runat="server" commandname="exporttopdf" imageurl="pdf.jpg" backcolor="white">
</command itemtemplate>
  
......
  
</asp:updatepanel>
</asp:content>

5 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 15 May 2012, 02:19 PM
Hello DANA,

Please check below code snippet.
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
            Button downloadpdf = item.FindControl("downloadpdf") as Button;
            ScriptManager.GetCurrent(Page).RegisterPostBackControl(downloadpdf);
        }
    }

Thanks,
Jayesh Goyani


0
DANA
Top achievements
Rank 1
Veteran
answered on 16 May 2012, 01:49 PM
Hi,

I still get an error and I think it's the same as before:

"error: sys.webforms.pagerequestmanagerservererrorexception: 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 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."

although it's a very informative error..... I still don't understand what to do to fix it.

one more thing-  when I wrote the part of code Jayesh Goyani suggested, I got an error that the downloadpdf button =nothing..
so I added that in the html page :
<asp:imagebutton id="downloadpdf ..... onclick="dowmload_click()"..>

and in the code behind I added on top:

dim isexport as boolean = false
  
protected sub downloadpdf_click()
isexport=true
radgrid1.mastertableview.exporttopdf()
end sub
  
  
protected sub RadGrid1_ItemCreated(sender as object , e as GridItemEventArgs ) handles radgrid1.itemcreated
        if typeof(e.Item is GridDataItem) AndAlso isexport then.....
  
  
  
' all the rest--

but I still have the same problem.

can you help?.....

0
DANA
Top achievements
Rank 1
Veteran
answered on 16 May 2012, 02:38 PM
Well, I figured the export part like that

As I said I added that in the html page :
<script  language="javascript">
function requeststart(sender,args) {
if (args.get_eventtarget().indexof("downloadpdf") >0
args.set_enableAjax(false);
}

.....


<
asp:imagebutton id="downloadpdf ..... onclick="dowmload_click()"..>

and in the function I wrote:

protected sub downloadpdf_click() 
isexport=true 
radgrid1.mastertableview.exporttopdf() 
if not clientscript.isStartUpScriptRegistered("downloadpdf") then
page.clientscript.registerstartupscript(me.gettype(), "downloadpdf", "requestStart();",true")
end if
end sub

* I also added in my master page <telerik: radajaxmanager clientevents-onrequeststart="requeststart"  ... >

now I have a new problem.
I get a pdf file but I need it to be in hebrew and even though I've found a good font for that, all the words are mixed backward (as if I'll get "dnuof" instead of "found"

Is there a way to fix it??
0
Richard
Top achievements
Rank 1
answered on 17 May 2012, 04:06 PM
Dana,

If you've not already seen this forum thread, I'd suggest that you review it:

grid export to pdf Arabic content problem

As pointed out by Telerik Admin: Daniel, RadGrid PDF export only supports left-to-right languages, as noted in the "Fonts/Unicode Support" section of the  PDF export documentation page:

"RadGrid's PDF exporting engine supports all languages that use left-to-right orientation when the appropriate Unicode font is set."

Hope this helps!
0
DANA
Top achievements
Rank 1
Veteran
answered on 20 May 2012, 06:19 AM
Well, it sure does help me to stop looking for a solution !

thanx :)
Tags
Grid
Asked by
DANA
Top achievements
Rank 1
Veteran
Answers by
Jayesh Goyani
Top achievements
Rank 2
DANA
Top achievements
Rank 1
Veteran
Richard
Top achievements
Rank 1
Share this question
or