Columns.Select引发错误-Kendo Grid-MVC

时间:2018-10-09 11:36:19

标签: kendo-grid kendo-asp.net-mvc

我正在使用Kendo网格(MVC)创建广播电台列表。网格代码如下:

@(Html.Kendo().Grid<ReportStationViewModel>(Model.ReportStations)
        .Name("ReportStations")
        .Columns(columns =>
        {
            columns.Select();
            columns.Bound(p => p.Station.StationFieldId).ClientTemplate("#= Station.StationFieldId #" + "<input type='hidden' name='ReportStations[#= index(data)#].Station.StationFieldId' value='#= Station.StationFieldId #' />")
                            .Title("Station Id").Filterable(f => f.Multi(true).Search(true));
            columns.Bound(p => p.Station.StationName).ClientTemplate("#= Station.StationName #" + "<input type='hidden' name='ReportStations[#= index(data)#].Station.StationName' value='#= Station.StationName #' />")
                .Title("Name").Filterable(f => f.Multi(true).Search(true));

            columns.Bound(p => p.Station.StationId).Hidden().ClientTemplate("#= StationId #" + "<input type='hidden' name='ReportStations[#= index(data)#].Station.StationId' value='#= Station.StationId #' />");
            columns.Bound(p => p.ReportStationId).Hidden().ClientTemplate("#= ReportStationId #" + "<input type='hidden' name='ReportStations[#= index(data)#].ReportStationId' value='#= ReportStationId #' />");
            columns.Bound(p => p.ReportId).Hidden().ClientTemplate("#= ReportId #" + "<input type='hidden' name='ReportStations[#= index(data)#].ReportId' value='#= ReportId #' />");
            columns.Bound(p => p.StationId).Hidden().ClientTemplate("#= StationId #" + "<input type='hidden' name='ReportStations[#= index(data)#].StationId' value='#= StationId #' />");
        })
        .Editable(e => e.Mode(GridEditMode.PopUp))
        .Filterable()
        .Selectable()
        .Mobile()
        .Events(e => e.Change("onChange").DataBound("onDataBind"))
        .DataSource(dataSource => dataSource
            .Ajax()
            .ServerOperation(false)
            .Events(events => events.Error("error_handler").Sync("sync_handler"))
            .Model(model =>
            {
                model.Id(s => s.ReportStationId);
                model.Field(f => f.ReportStationId).Editable(false);
            })
            .Read(read => read.Action("GetAllRead", "ReportStations").Data("onData"))
            .Destroy(destroy => destroy.Action("RemoveStation", "ReportStations"))
        ))

ViewModel如下:

public class ReportViewModel{
public int ReportId { get; set; }
public string ReportName { get; set; }
public virtual Organization Organization { get; set; }
public List<ReportStationViewModel> ReportStations { get; set; }}



public class ReportStationViewModel{
public int ReportStationId { get; set; }
public int ReportId { get; set; }
public int StationId { get; set; }
public virtual StationViewModel Station { get; set; }
public ICollection<ReportStationPlatformViewModel> ReportStationPlatforms { get; set; }}

它正确填充了网格,我可以看到我需要的所有信息。但是,当我尝试选择一行时,不会对其进行检查。并且不会引发任何JS错误。

你知道我在做什么错吗?

1 个答案:

答案 0 :(得分:0)

尝试删除网格的 .Selectable()。由于某些原因,它不能与复选框选择一起使用。