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

Setting Padding To Header Text

1 Answer 16 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pritam
Top achievements
Rank 1
Pritam asked on 29 Nov 2020, 07:09 AM

I'm using the Rad Grid's ExportToPDF functionality in that i want to set left padding to header text. i tried to set programmatically but it doesn't work.

any solution for this..? please check attachment for your understanding.

1 Answer, 1 is accepted

Sort by
0
Doncho
Telerik team
answered on 02 Dec 2020, 12:26 PM

Hi Pritam,

You can try setting the desired styles in the ItemCommand event when ExportToPdf command is fired.

Here is a sample for looping through all header cells applying some custom styles:

protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.ExportToPdfCommandName)
    {
        var columns = RadGrid1.MasterTableView.Columns;
        foreach (GridColumn col in columns)
        {
            var headerCell = RadGrid1.MasterTableView.GetHeaderCellByColumnUniqueName(col.UniqueName);
            headerCell.HorizontalAlign = HorizontalAlign.Left;
            headerCell.Style.Add("padding-left", "5px");
        }
    }
}

Please give it a try and let me know if how it goes!

Kind regards,
Doncho
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Pritam
Top achievements
Rank 1
Answers by
Doncho
Telerik team
Share this question
or