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

PDF Export - Header text alignment

1 Answer 42 Views
Grid
This is a migrated thread and some comments may be shown as answers.
AnneArents
Top achievements
Rank 1
AnneArents asked on 09 Jul 2013, 02:49 PM
Hi,

I'm trying to export a radgrid to PDF and set the alignment of the headers.
I've been through a lot of posts on this forum, but nothing I can find seems to work.

Right now I have this:

Private Sub rgLec_ItemCreated(sender As Object, e As GridItemEventArgs) Handles rgLec.ItemCreated
        If (bPrintReport And (TypeOf e.Item Is GridHeaderItem)) Then
            For Each cell As TableCell In e.Item.Cells
                cell.Style("text-align") = "left"
            Next
        End If
End Sub

However, this doesn't change anything. The header text is still centered.
Can anyone tell me what I'm doing wrong?

Cheers,
CJ

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 10 Jul 2013, 09:28 AM
Hi CJ,

Please try the following code snippet .Let me know if any concern.

VB:
Private IsExport As Boolean = False
Protected Sub RadGrid1_ItemCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs)
    If e.CommandName = RadGrid.ExportToPdfCommandName Then
        IsExport = True
    End If
End Sub
 
Protected Sub RadGrid1_PreRender(sender As Object, e As EventArgs)
    If IsExport Then
        For Each header As GridHeaderItem In RadGrid1.MasterTableView.GetItems(GridItemType.Header)
            For Each cell As TableCell In header.Cells
                cell.Style("text-align") = "left"
            Next
        Next
    End If
End Sub

Thanks,
Princy
Tags
Grid
Asked by
AnneArents
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or