Dynamically setting cell background color on PDF Export

2 posts, 0 answers
  1. Chuck
    Chuck avatar
    17 posts
    Member since:
    Oct 2018

    Posted 04 Oct 2018 Link to this post

    I have a RadGrid that I set the cell background colors dynamically based on cell value but none of this formatting carries over to PDF like it does in Excel export.

    an someone point me to any sources I can use to program this?

  2. Rumen
    Admin
    Rumen avatar
    13804 posts

    Posted 05 Oct 2018 Link to this post

    Hello Chuck,

    Please review the following article on the topic: Appearance, i.e.

    bool isExport = false;
    protected void Button1_Click(object sender, EventArgs e)
    {
        isExport = true;
        RadGrid1.MasterTableView.ExportToPdf();
    }
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem && isExport)
            e.Item.Style["background-color"] = "#888888";
    }

    In the cases, where Rebind won't be invoked you can apply the styles directly:

    protected void Button1_Click(object sender, EventArgs e)
    {
        foreach (GridDataItem item in RadGrid1.Items)
            item.Style["background-color"] = "#888888";
        RadGrid1.MasterTableView.ExportToPdf();
    }


    Regards,
    Rumen
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top