Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing row color in Kendo MVC grid, using RowAction

I'm hoping to use RowAction with a lambda to set the background color of a few rows of data in a Grid.

<%: Html.Kendo().Grid<HomeController.SuccessfulBuildsByDevice>()
                        .Name("Grid")
                        .Columns(columns =>
                        {                   
                            columns.Bound(p => p.A);
                            columns.Bound(p => p.B);
                        })
                        .Scrollable()
                        .Sortable()
                        .Filterable()
                        .RowAction(row =>
                            {
                                if(row.DataItem.A > row.DataItem.B)
                                    row.HtmlAttributes["style"] = "background:red";
                            })
                        .HtmlAttributes(new { style = "height:500" })  
                        .DataSource(dataSource => dataSource
                            .Ajax()
                            .Read(read => read.Action("_GetData", "Home"))
                            .ServerOperation(false)
                        )
                    %>

However, when I use the above the RowAction() doesnt seem to be called. I tried setting a breakpoint, etc. Am I missing something in the intended use of RowAction(), does anyone see an obvious problem?

like image 812
stuck Avatar asked Dec 30 '13 18:12

stuck


People also ask

How do you add a style to Kendo grid MVC?

For styling individual cells of grid with a template: In order to format Kendo Grid Column value with conditionally chosen action you can use the example below. For more information: How Do I Have Conditional Logic in a Column Client Template? Show activity on this post.


1 Answers

the problem is .Ajax() and .RowAction() are mutually exclusive

http://www.kendoui.com/forums/kendo-ui-web/grid/ajax-binding-and-rowaction-conflict-.aspx

like image 153
stuck Avatar answered Oct 13 '22 11:10

stuck