Kendo UI Grid - Update to send entire list when inline editing

Is it possible with a Kendo UI Grid to send back to the server a list of all the lines that have changed, or all the lines contained in the grid back to the server at once? Because when in InLine editing mode, when you save, the _Update event will be fired for each element changed in the grid. The thing is, I need all of them at once. Here is my code:

@(Html.Kendo().Grid<StrategyParameterModel>()
    .Name("strategyParameters")
    .Columns(columns =>
    {
      columns.Bound(c => c.Id).Width(170);
      columns.ForeignKey(p => p.ParamType, (System.Collections.IEnumerable)ViewData["paramTypes"], "Key", "Value").Title("Param Type").Width(200);
      columns.Bound(c => c.Key);
      columns.Bound(c => c.Value);
      columns.Bound(c => c.MinimumValue);
      columns.Bound(c => c.MaximumValue);
      columns.Bound(c => c.IncrementalValue);
    })
     .ToolBar(toolbar =>
     {
       toolbar.Create();
       toolbar.Save();
     })
    //.ColumnMenu()
    .Editable(editable => editable.Mode(GridEditMode.InCell))
    .Pageable(pager =>
        pager.Refresh(true)
    )
    .Navigatable()
    .Resizable(resize => resize.Columns(true))
    .Sortable(sortable =>
    {
      sortable.SortMode(GridSortMode.SingleColumn);
      sortable.AllowUnsort(false);
    })
    .Filterable(filterable => filterable.Mode(GridFilterMode.Menu))
    .Scrollable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(100)
        .Model(model =>
        {
          model.Id(p => p.Id);
          model.Field(p => p.Id).Editable(false);
        })
        .Read(read => read.Action("StrategyParameter_Read", "StrategySets").Data("getStrategySetId"))
        .Update(update => update.Action("StrategyParameter_Update", "StrategySets").Data("getStrategySetId"))

        .Sort(sort => sort.Add("Id").Descending())
    )
    .Deferred()
)

Controller:

    public ActionResult StrategyParameter_Update([DataSourceRequest]DataSourceRequest request, StrategyParameterModel parameters, int? strategySetId)
    {
        // parameters is one line only, should be a list of all lines...
        var result = string.Empty;
        return Json(result);
    }

Upvotes: 0

Views: 475

Answers (1)

Ross Bush
Ross Bush

Reputation: 15185

I bet this could be as simple as enabling Batch Edit Mode on th edata source.

.DataSource(dataSource => dataSource        
    ...     
    .Batch(true)
    ...
)

Upvotes: 1

Related Questions