10 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 21 Feb 2014, 11:25 AM
Hi,
You may try a similar approach as shown in the sample code snippet below:
ASPX:
C#:
Thanks,
Princy
You may try a similar approach as shown in the sample code snippet below:
ASPX:
<asp:Button ID="Button1" runat="server" Text="Export" OnClick="Button1_Click" /><div> <telerik:RadGrid ID="RadGrid1" runat="server" Width="300px" AllowPaging="true" OnNeedDataSource="RadGrid1_NeedDataSource" OnItemCreated="RadGrid1_ItemCreated" nPdfExporting="RadGrid1_PdfExporting"> <ExportSettings ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true" /> </telerik:RadGrid></div>C#:
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e){ DataTable table = new DataTable(); table.Columns.Add("Col1"); table.Columns.Add("Col2"); for (int i = 0; i < 100; i++) table.Rows.Add(i, i); RadGrid1.DataSource = table;}protected void RadGrid1_PdfExporting(object sender, GridPdfExportingArgs e){ string replacement = "</tbody></table><?hard-pagebreak?><table width='{0}'><colgroup>{1}</colgroup><tbody><tr pageBreak"; string cols = ""; foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns) if (col.IsEditable) cols += "<col />"; e.RawHTML = e.RawHTML.Replace("<tr pageBreak", String.Format(replacement, RadGrid1.Width.ToString(), cols));}protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e){ if (e.Item.ItemIndex % 10 == 0 && e.Item.ItemIndex > 1 && e.Item is GridDataItem) { e.Item.Attributes.Add("pageBreak", "pageBreak"); }}protected void Button1_Click(object sender, EventArgs e){ RadGrid1.MasterTableView.ExportToPdf();}Thanks,
Princy
0
Tofan
Top achievements
Rank 1
answered on 21 Feb 2014, 12:37 PM
Thanks. There is a possibility to write programaticly a text for the right cell of the page footer of the current page inside PdfExporting? If so how? Thanks for the help.
0
Princy
Top achievements
Rank 2
answered on 24 Feb 2014, 07:53 AM
Hi,
You can have the footer text written programmatically as follows:
C#:
Thanks,
Princy
You can have the footer text written programmatically as follows:
C#:
protected void RadGrid1_PdfExporting(object sender, GridPdfExportingArgs e){ RadGrid1.ExportSettings.Pdf.PageFooter.RightCell.Text = "Footer Text";}Thanks,
Princy
0
Tofan
Top achievements
Rank 1
answered on 24 Feb 2014, 08:14 AM
I know this. But I have to set a page number for the export pdf document page footer. And the previous answer told me I can force break my pdf document after a number of arbitrary radgrid rows through the pdfexporting handler and the html code. There is any possibility to set the pdf document page number like Page x of y using pdfexporting handler and the html code like it was to force the pdf to create another page after a set number of pages? Thank you for your time and help.
0
Accepted
Princy
Top achievements
Rank 2
answered on 24 Feb 2014, 11:44 AM
Hi,
You may try something like shown below.
C#:
Thanks,
Princy
You may try something like shown below.
C#:
int count = 1;protected void RadGrid1_PdfExporting(object sender, GridPdfExportingArgs e){ for (int i = 1; i <= count; i++) { RadGrid1.ExportSettings.Pdf.PageFooter.RightCell.Text = "Page" + footerMiddleCell + "of" + count; }}protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e){ if (e.Item.ItemIndex % 10 == 0 && e.Item.ItemIndex > 1 && e.Item is GridDataItem) { count += 1; }}Thanks,
Princy
0
Tofan
Top achievements
Rank 1
answered on 24 Feb 2014, 12:06 PM
And footerMiddleCell from where do I take?
0
Accepted
Princy
Top achievements
Rank 2
answered on 24 Feb 2014, 12:13 PM
Hi,
I'm sorry, I forgot to place that code. Please set the below code snippet.
C#:
Thanks,
Princy
I'm sorry, I forgot to place that code. Please set the below code snippet.
C#:
string footerMiddleCell = "<?page-number?>";Thanks,
Princy
0
Tofan
Top achievements
Rank 1
answered on 24 Feb 2014, 12:25 PM
Thanks a lot. It worked.
0
Tofan
Top achievements
Rank 1
answered on 24 Feb 2014, 12:27 PM
I have a radgrid that the user can group by collumns. He can also collapse one, or multiple groups. When exporting to pdf is it possible not to display the rows that were part of the collapsed groups? If it is possible can I get an example ,demo, or hint to make this work,please?
Thank you for you help.
Thank you for you help.
0
Princy
Top achievements
Rank 2
answered on 25 Feb 2014, 05:10 AM
Hi,
I guess you have grouping enabled for your RadGrid and want to Export to PDF only the Expanded rows. Please try the following code snippet.
ASPX:
C#:
Thanks,
Princy
I guess you have grouping enabled for your RadGrid and want to Export to PDF only the Expanded rows. Please try the following code snippet.
ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" RetainExpandStateOnRebind="true" ShowGroupPanel="true" OnItemCommand="RadGrid1_ItemCommand"> <MasterTableView CommandItemDisplay="Top"> <CommandItemSettings ShowExportToPdfButton="true" /> <Columns> . . . </Columns> </MasterTableView> <ClientSettings AllowDragToGroup="true"> </ClientSettings></telerik:RadGrid>C#:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e){ if (e.CommandName == RadGrid.ExportToPdfCommandName) { foreach (GridGroupHeaderItem item in RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader)) { if (!item.Expanded) { item.Visible = false; } } }}Thanks,
Princy