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

apply backcolor to specific rows

2 Answers 90 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Srinivasa Rao
Top achievements
Rank 1
Srinivasa Rao asked on 26 Mar 2011, 06:37 AM
Hi,

I am using the radGrid control to evaluate the product. I need clarification on following scenarios.
Please clarify on these how radGrid supports these:

1) I have a radGrid having morethan 10 rows, where one of the column is Date column.
2) can you give me an example of how to change the backcolor of the rows whose records with lessthan 1/1/2000 with black color
3) I had implemented the sorting on the radGrid with:
<telerik:radGrid AllowSorting="true" ..........>
<M....>
<Columns>
<telerik:GridBoundColumn SortExpression="fullname" ..........>
</Columns>

But unfortunately sorting is not happening on grid.

Please clarify the above thing. And the same implementation can I use in DotNetNuke?

Thanks,
Srinu dhulipalla

2 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 26 Mar 2011, 06:46 AM
hi Srinivasa Rao Dhulipalla,


protected void Data_OnItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
        if (Convert.ToDateTime(item.Cells[3].Text) < DateTime.Today )
        {
            item.Cells[3].ForeColor = System.Drawing.Color.Red;
        }
    }
}

or
http://www.telerik.com/community/forums/winforms/gridview/radgridview-row-formatting.aspx

check this link.

Thanks,
Jayesh Goyani
0
Princy
Top achievements
Rank 2
answered on 28 Mar 2011, 10:47 AM
Hello Srinu dhulipalla,


Follow the same logic as Jayesh suggested to achieve the functionality.

When accessing the cell value a better approach is using "ColumnUniqueName".  Because of features such as column reordering and grouping, the index of individual columns can change on the client. This means that using indexes to access individual cells in the Cells collection of a row is not a reliable method of obtaining a cell in a particular column.

So, to provide a reliable way of locating the cell in a particular column, each column in the grid has a UniqueName property of type string, use the ColumnUniqueName to access cell.

I got the information from Telerik online documentation:
Accessing cells and rows


Regards,
Princy.
Tags
Grid
Asked by
Srinivasa Rao
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Princy
Top achievements
Rank 2
Share this question
or