Asp.net mvc telerik剑道网格中未调用单元格操作

Asp.net mvc telerik剑道网格中未调用单元格操作,asp.net-mvc,telerik-grid,Asp.net Mvc,Telerik Grid,我试图改变telerik网格中单元格中文本的颜色。 我正在使用ASP.NETMVC 以下是我试图做到这一点的方式: @{ Html.Kendo() .Grid<DellZapFast.BackOffice.ViewModels.EventInstance.EventInstanceViewModelMin>() .Name("grid") .Columns(c =>

我试图改变telerik网格中单元格中文本的颜色。 我正在使用ASP.NETMVC 以下是我试图做到这一点的方式:

@{
        Html.Kendo()
             .Grid<DellZapFast.BackOffice.ViewModels.EventInstance.EventInstanceViewModelMin>()
             .Name("grid")
             .Columns(c =>
             {
                 c.Bound(a => a.Country);
                 c.Bound(a => a.Town);
                 c.Bound(a => a.StartDate).Format("{0:d}");
                 c.Bound(a => a.EndDate).Format("{0:d}");
                 c.Bound(a => a.GlobalEventName).Title("Type");
                 c.Bound(a => a.Id)
                      .Title("Actions")
                      .Sortable(false)
                      .Filterable(false)
                      .Width(180)
                      .ClientTemplate
                      (
                            "<button class='btn btn-default' data-toggle='modal' rel='tooltip' data-original-title='Dashboard' title='Dashboard' onclick='goToDashboard(\"" + "#=Id#" + "\")'><span class='glyphicon glyphicon-dashboard'></span></button>" +
                            "<button class='btn btn-default' data-toggle='modal' rel='tooltip' data-original-title='Edit this event Instance' title='Edit this eventInstance' data-target='\\#editeventInstance' onclick='getEditeventInstance(\"" + @Url.RouteUrl("EditEventInstance", new { eventInstanceId = "#=Id#" }) + "\")'><span class='glyphicon glyphicon-edit'></span></button>" +
                            "<button class='btn btn-default' data-toggle='modal' rel='tooltip' data-original-title='Copy this event Instance' title='Copy this event Instance' data-target='\\#copyEventInstance' onclick='getCopyEventInstance(\"" + @Url.RouteUrl("CopyEventInstance", new { eventInstanceId = "#=Id#" }) + "\")'><span class='glyphicon glyphicon-export'></span></button>" +
                            "<button type='button' class='btn btn-default' data-toggle='modal' rel='tooltip' data-original-title='Delete this event' title='Delete this event' data-target='\\#deleteeventInstance' onclick='deleteeventInstance(\"" + @Url.Action("delete", "EventInstance", new { eventInstanceId = "#=Id#" }) + "\");'><span class='glyphicon glyphicon-remove'></span></button>"
                      );
             })
         .CellAction(cell =>
         {
             // if (cell.Column.Title == "Registered")
             cell.HtmlAttributes["style"] = "background:red;";
         })
         .Scrollable(s => s.Height("auto"))
         .Sortable()
         .Groupable()
         .Filterable()
         .Pageable(p => p.Refresh(true).ButtonCount(3))
         .Deferred()
         .DataSource(dataSource => dataSource
            .Ajax()
            .Read(read => read.Action("GetEvents", "eventInstance"))
            .PageSize(50)
         )
         .ToolBar(toolbar =>
                  toolbar.Template(
                    @<text>
                        @if (@ViewBag.NumberOfEventsArchived > 0)
                        {
                            <button id="btn-event-archived" class="btn btn-default"> @ViewBag.NumberOfEventsArchived Archived </button>
                        }
                    </text>)
                                       )
                      .Deferred()
             .Render();
CellAction的lambda应该为网格中的每个单元格调用,但是什么都没有发生,当我在CellAction lambda中放置断点时,它永远不会中断。 我没有收到任何错误,只是没有做任何事情。
我知道我的代码应该更改背景颜色而不是文本颜色,但我只是从文档中获取了这段代码,并试图找出它为什么不起作用。

注意CellAction仅适用于服务器端数据绑定。
例如:

对于ajax绑定,只需订阅一个javascript绑定事件并在其中更改单元格样式

         .CellAction(cell =>
         {

             cell.HtmlAttributes["style"] = "background:red;";
         })
@(Html.Kendo().Grid(Model.Data)    
      .Name("Grid")
      .Columns(columns => {
          columns.Bound(c => c.Id);
          columns.Bound(c => c.Name).HtmlAttributes(new { style = "background:red;" });
      })
      .CellAction(cell =>
      {
          if (cell.Column.Title == "Name")
          {
              cell.HtmlAttributes["style"] = "background:blue;";
          }
      })
      .Pageable()
      .Sortable()
      .Scrollable() 
      .Filterable()
      .Groupable()
      )