Not able to set header text to bold in PDF.

6 posts, 0 answers
  1. Radha
    Radha avatar
    19 posts
    Member since:
    Dec 2012

    Posted 03 Dec 2012 Link to this post

    How to set header text to bold while exporting to PDF.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 03 Dec 2012 Link to this post

    Hi,

    Try the following code to achieve your scenario.
    C#:
    protected void RadGrid2_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.ExportToPdfCommandName)
        {
            GridHeaderItem item = (GridHeaderItem)RadGrid2.MasterTableView.GetItems(GridItemType.Header)[0];
            foreach (TableCell cell in item.Cells)
            {
               cell.Style.Add("font-weight", "bold");
            }
         }
    }

    Thanks,
    Shinu.
  3. Radha
    Radha avatar
    19 posts
    Member since:
    Dec 2012

    Posted 04 Dec 2012 Link to this post

    Thanks for the reply.

    Unfortunately it is not working if i write the foreach loop in item command.so can please suggest me other ways to set the style to column header.

    Below is the code :

    protected

     

    void radGrid1_ItemCreated(object sender, GridItemEventArgs e)

     

    {


     

    if (e.Item is GridHeaderItem && isExport)

     

    {

     

    foreach (TableCell cell in e.Item.Cells)

     

    {

    cell.Style.Add(

    "font-weight", "bold");

     

    cell.Style.Add(

    "border-width", "thin");

     

    cell.Style.Add(

    "font-family", "Verdana");

     

    cell.Style.Add(

    "border-style", "solid");

     

    cell.Style.Add(

    "font-size", "8pt");

     

    }


    }
    }
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 04 Dec 2012 Link to this post

    Hi,

    Try modifying the code as shown below.
    C#:
    bool isexport = false;
    protected void RadGrid2_ItemCreated(object sender, GridItemEventArgs e)
    {
     isexport = true;
     if (e.Item is GridHeaderItem && isexport)
     {
       foreach (TableCell cell in e.Item.Cells)
       {
          cell.Style.Add("font-weight", "bold");
          cell.Style.Add("font-family", "Verdana");
          cell.Style.Add("font-size", "8pt");
       }
     }
    }

    Thanks,
    Shinu.
  5. Radha
    Radha avatar
    19 posts
    Member since:
    Dec 2012

    Posted 05 Dec 2012 Link to this post

    Still the issue exists even if i set the isexport true.
  6. Radha
    Radha avatar
    19 posts
    Member since:
    Dec 2012

    Posted 06 Dec 2012 Link to this post

    Hi shinu,

      I solved the issue to set the header text to bold.In our code  somewhere after apply font-weight to bold for each cell,we are setting the header text as

    "<b>Test</b>"

     

    ; because of the bold tag while rendering it was not taking the style that i applied as you suggested above.
    so i replaced bold tag with span as below:
    "<span style='font-family:Verdana;font-weight:bold'>Test</span>"; and removed the cell style and it worked well.

    Thanks for the support.
    Radha

     

Back to Top