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

[Solved] how to change background for particular row

0 Answers 132 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
ajmal
Top achievements
Rank 1
ajmal asked on 25 Mar 2011, 05:21 PM
hello all,

i 'm using telerik MVC grid where i need to change the backgroung color of row for "VOLUMES" and "RA".
below code color our entire grid...
attached the grid...

@(Html.Telerik().Grid(Model.Data)
                                       .Name("Grid")
                                       .Columns(columns =>
                                       {
                                           foreach (var column in Model.Data.Columns)
                                           {
                                               columns.Bound(column.ToString()).Encoded(false);
                                           }
                                       })
                                            .RowAction(row =>
                                            {
                                                if (row.DataItem.DataView[1].Row.ItemArray[0].ToString().ToLower() == "volumes")
                                                {
                                                      
                                                    //row.HtmlAttributes["style"] = "background:black;color:white;";
                                                }
                                            })
                                            .CellAction(cell =>
                                            {
                                                if (cell.Column.Member != "Column1")
                                                {
                                                    cell.HtmlAttributes["style"] = "text-align:center";
                                                }
                                                if (cell.Column.Member == "Column1")
                                                {
                                                    for (int i = 0; i < cell.DataItem.DataView.Count; i++)
                                                    {
                                                        for (int j = 0; j < cell.DataItem.DataView[0].Row.ItemArray.Count(); j++)
                                                        {
                                                            switch (cell.DataItem.DataView[i].Row[j].ToString().ToLower())
                                                            {
                                                                case "retail analysis":
                                                                    cell.DataItem.DataView[i].Row[j] = "RA";
                                                                    //cell.HtmlAttributes["style"] = "background:black;color:white;";
                                                                    break;
                                                                //case "volumes":
                                                                //    cell.DataItem.DataView[i].Row[j] = Html.LocalizeValue("lbl_RETAILANALYSIS");
                                                                //    break;
                                                            }
                                                        }
                                                    }
                                                }
                                            })
                                       )
Tags
Grid
Asked by
ajmal
Top achievements
Rank 1
Share this question
or