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

Setting the color for specific rows

4 Answers 35 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
James Fallaw
Top achievements
Rank 1
James Fallaw asked on 21 May 2010, 03:03 PM
I want to set the color for all cells in certain rows of the grid (like when an email is high priority, or if a payment is past due).  It seems the best place to do this is the ItemDataBound event, but I was wondering if there is any way to set an attribute for the entire row, or if I have to explicitly specify every cell in the row and set its color property.

Thanks

4 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 21 May 2010, 03:15 PM
Hello James,

Well, yes, you can set a style to the row, there is no need to apply it to each cell separately. Alternatively, you can set CssClass and add the styles in an external CSS file.

Greetings,
Dimo
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Princy
Top achievements
Rank 2
answered on 21 May 2010, 03:17 PM
Hello,

I hope the following links which shows how to access the cells, would be helpful in achieving this.
Accessing Cells and Rows
Accessing cells and rows - Documentation

Thanks,
Princy.
0
James Fallaw
Top achievements
Rank 1
answered on 21 May 2010, 03:59 PM
I have tried setting the style on the row using both the Style property and the ApplyStyle method, but neither one appears to work(for the row).  For example, I am currently running the following code (in my ItemDataBound event handler):

Dim dataBoundItem as GridDataItem = DirectCast(e.Item, GridDataItem)
If ChangeColor then
   Dim primaryStyle as New Style()
   primaryStyle.ForeColor = Drawing.Color.Red

   dataBoundItem.ApplyStyle(primaryStyle)
   dataBoundItem.Item("DueDate").ApplyStyle(primaryStyle)
End If

When it runs, only the DueDate column changes color.

0
Dimo
Telerik team
answered on 24 May 2010, 09:18 AM
Hi James,

It seems to me that you have some CSS styles on the page, which define text color or table cells. This could be a reason why color defined for rows does not apply.

You should remove the table cell color styles in order to be able to set color to rows. Alternatively modify the cell color styles to not influence RadGrid.

Greetings,
Dimo
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
General Discussions
Asked by
James Fallaw
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Princy
Top achievements
Rank 2
James Fallaw
Top achievements
Rank 1
Share this question
or