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

RadGrid styling of rows - fonts and colors

1 Answer 452 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sunit Carpenter
Top achievements
Rank 1
Sunit Carpenter asked on 08 Apr 2016, 04:28 PM

 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?

 

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 13 Apr 2016, 08:49 AM
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.
Tags
General Discussions
Asked by
Sunit Carpenter
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or