RadGrid styling of rows - fonts and colors

2 posts, 0 answers
  1. Sunit Carpenter
    Sunit Carpenter avatar
    4 posts
    Member since:
    Jul 2012

    Posted 08 Apr Link to this post

     Hi,

    I am a RadGrid newbie and would appreciate help with a few items.

    I am using RadGrid in a SharePoint 2010 visual web-part.  I am also using server side code.

    Skin = office2010blue

    Here are my questions:

    1. How do I declaratively set the font for the rows (not just the header)?

    2. How do I specify the columns and their width?

    3. How do I at runtime set the background color of individual cells and for entire row?

    4. How do I stop inheriting the font color from twitter bootstrap css?

     

  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 13 Apr Link to this post

    Hi Sunit,

    You can change the appearance of the cells/rows within the OnItemDataBound event of the grid:
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
            item.CssClass = "yourClass"; // adding custom class to the TR element
            item.BackColor = System.Drawing.Color.Beige; //Changing color for the entire row
            item["ID"].BackColor = System.Drawing.Color.Red; //Changing color for particular cell
        }
    }

    As for the last question, since there is no such concept as removing/stopping the inheritance, adding class name to the elements and using higher specificity than the applied styles will override the inherited styles.

    Hope this helps.


    Regards,
    Konstantin Dikov
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top