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

RadGrid Export to PDF

5 Answers 205 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Olga
Top achievements
Rank 1
Olga asked on 04 Nov 2010, 08:28 PM
Hello,

We are evaluating your product. It works perfect.
The only question I have right for now is related to export to PDF.

I cannot find a way to add something like "Page 1 of 9", "Page 2 of 9" and so on to the footer of the pages in exported document. I'm looking at your example with Sushi Menu and my export work exactly like the example: there is no footer with page numbers.
Please advice how can I get the needed functionality.

Best Regards,
Olga

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 Nov 2010, 11:02 AM
Hello Olga,


One suggestion to show the page information is adding a Label control in the Footer of grid and setting the Text accordingly. Access the GridFooterItem from code behind (in ItemCreated event) and add the control to item after getting the Page information.
Accessing cells and rows


-Shinu.
0
Olga
Top achievements
Rank 1
answered on 05 Nov 2010, 02:49 PM
Hello Shinu,

Thank you for reply.

The problem is that Footer is created only once for the grid. So all pages in the exported document got the same footer. 
I'm already ready to create RawHtml myself, but then I have a problem of knowing what will be the last row of the page and where I should add a row that will be the footer.

Please advice. I'm pretty sure that I'm not the only person who needs this functionality.

Regards,
Olga
0
Daniel
Telerik team
answered on 10 Nov 2010, 10:14 PM
Hello Olga,

I already answered to your support ticket. Unfortunately this functionality is not supported in the current version of RadControls for ASP.NET AJAX.
Please excuse us for any inconvenience caused.

Best 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
Phillip
Top achievements
Rank 1
answered on 06 Dec 2011, 10:33 PM
I have incorporated page count into my pdf using the following. 

Dim mycount As Integer = 1
Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated
    If e.Item.ItemIndex Mod 7 = 0 AndAlso e.Item.ItemIndex > 1 AndAlso TypeOf e.Item Is GridDataItem Then
          'count the pages
          mycount = mycount + 1
    End If
End Sub
Count the pages in the itemcreated event.  I chose a record size of 7 per page.  On the eigth record is adds 1 to mycount

Protected Sub RadGrid1_PdfExporting(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridPdfExportingArgs) Handles RadGrid1.PdfExporting
    'Split Domain\Username into strUID and strDomain
    Dim arrayUID As Array = Split(User.Identity.Name, "\")
    Dim strDomain As String = arrayUID(0)
    Dim strUID As String = arrayUID(1)
    Dim replacement As String = ""
    For i As Integer = 1 To mycount
        e.RawHTML = Replace(e.RawHTML, "Print Column", "Page " & i & " of " & mycount, 1, 1)
    Next
End Sub
During the pdfExporting this goes in and replaces the column header, "Print Column", with Page x of xx.  It only replaces one instance each time while counting up to mycount.  You can easily apply this to the header by specifying a page header such as "{page} of {totalpages}" and then do the same replace method to replace the header with the current and total pages.   

0
Daniel
Telerik team
answered on 09 Dec 2011, 01:04 PM
Hello Phillip,

Thank you for sharing your solution with the community. You may submit a simple project in the code-library section if you want to make it accessible for a wider audience.
Code libraries
Using the Code Library

Best regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
Olga
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Olga
Top achievements
Rank 1
Daniel
Telerik team
Phillip
Top achievements
Rank 1
Share this question
or