Kendo Grid动态列并更新批量值

时间:2015-05-09 10:48:23

标签: datatable kendo-ui kendo-grid updatemodel

我通过动态数据表在Kendo Grid中拥有动态列,一切都很好,

问题是,Kendo网格没有更新控制器中的批量更改值。请仔细看看,请帮助我。

 @model System.Data.DataTable
@(Html.Kendo().Grid<dynamic>()
    .Name("GridfilterHandler")
    .Columns(columns =>
    {
        foreach (System.Data.DataColumn column in Model.Columns)
        {
            var c = columns.Bound(column.ColumnName).EditorTemplateName("gridColumn");
            if (column.ColumnName == "ShowCheck")
            {
                columns.Template(@<text></text>).ClientTemplate("<input type='checkbox' #= ShowCheck ? checked='checked':'' # class='chkbx' />")
                                             .HeaderTemplate("<input type='checkbox' id='masterCheckBox' onclick='checkAll(this)'/>").Width(200);
            }
        }
        columns.Command(cmd => cmd.Edit());
    })

    .Pageable()
    .Sortable()
     .ToolBar(toolbar =>
       {
           toolbar.Save();
       })
     .Editable(ed => ed.Mode(GridEditMode.InCell))
   //  .Events(events => events.SaveChanges("onSaveChanges"))
    .Filterable()
    .Groupable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model =>
        {
            foreach (System.Data.DataColumn column in Model.Columns)
            {
                model.Field(column.ColumnName, column.DataType);
            }
        })
        .Model(model =>
            {
                var id = Model.PrimaryKey[0].ColumnName;
                model.Id(id);
                foreach (System.Data.DataColumn column in Model.Columns)
                {
                    model.Field(column.ColumnName, column.DataType);
                    // var field = model.Field(column.ColumnName, column.DataType);
                }
            })
        .Batch(true)
        .Read(read => read.Action("readfilterHandlerGrid", "Customize", new { filterTitle = Request.QueryString["filterTitle"] }))
        .Update(update => update.Action("updatefilterHandlerGrid", "Customize"))
    )
)

public ActionResult updatefilterHandlerGrid([DataSourceRequest] DataSourceRequest request, IEnumerable<dynamic> items)      
        {...............
}

public ActionResult updatefilterHandlerGrid([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable<DataTable> products)
{.......................
}

我已尝试过以上更新事件,但我得到空值。

1 个答案:

答案 0 :(得分:1)

    public ActionResult Update([DataSourceRequest] DataSourceRequest request, FormCollection model)
    {
        foreach (var key in model.Keys)
        {
            //Build you update query here
        }

此处为解决方案