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

[Solved] Want to change the color of selected row

1 Answer 45 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.
Tomer
Top achievements
Rank 1
Tomer asked on 27 Aug 2012, 11:11 AM
Hi,

I have a problem with the grid in MVC Extension for ASP.NET (NOT the Kendo)!

the problem is that I want to color one of the rows in the grid and I didn't succeed.

here is the code:

@(Html.Telerik().Grid<CRC.Models.CRC_NetIQ_CriticalServer>()
                    .Name("Gridl11")
                    .Resizable(resizing => resizing.Columns(true))
                    .Columns(columns =>
                        {
                            columns.Bound(o => o.EventsPerSecPerCC_CCName).Width(100);
                            columns.Bound(o => o.EventsPerSecPerCC_EventsPerHour).Width(100);
                            columns.Bound(o => o.EventsPerSecPerCC_EventsPerMinute).Width(100);
                            columns.Bound(o => o.EventsPerSecPerCC_EventsPerSec).Width(100);
                            columns.Bound(o => o.EventsPerSecPerCC_TotalEventsPer24H).Width(100);
                            //.ClientTemplate("<# if( Status == 'Running') { #> <img width='16' height='16' alt='Running' src='" + Url.Content("~/Content/Images/buttonCircle_blank_green.png") + "' /> <# } else {#> <img width='16' height='16' alt='Not Running' src='" + Url.Content("~/Content/Images/buttonCircle_blank_red.png") + "' /> <# } #>").Title("Status").Width(120).HtmlAttributes(new { style = "text-align: center;" });                                                              
                        })                                                                 
                        .DataBinding(dataBinding => dataBinding.Ajax().Select("_AjaxBinding", "Home"))
                        .Pageable()
                        .Sortable()
                        .ClientEvents(events => events.OnRowSelected("onRowSelected"))
                        .Selectable()
                        .Scrollable()
                        .Groupable()
                        .Filterable()
                                        .RowAction(row =>
                                        {
                                            if (row.DataItem.EventsPerSecPerCC_CCName.Equals("A44") == true)
                                            {
                                                row.HtmlAttributes["style"] = "background:red;";
                                            }
                                        }
                                                )   
 
I know that my problem is in the RowAction.

Please help me it is urgent for my project.

10X. 

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 28 Aug 2012, 10:19 AM
Hi Tomer,

RowAction() can be used with server-side databinding. With Ajax binding you can use the RowDataBound event to make styling customizations on the fly.

All the best,
Dimo
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
Tags
Grid
Asked by
Tomer
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or