I have a kendo grid that let's user add the rows manully. Once users are done adding rows, There is a button that uses Ajax post to post data to controller action.
How can I pass the data from grid as Enumerable of model to the action
How can I pass the data from grid as Enumerable of model to the action
@(Html.Kendo().Grid(Of PEERS.ECFPropertyModel).Name("ECFProperty"). Columns(Sub(cols) cols.Bound(Function(it) it.PropertyID).ClientTemplate("<input type='checkbox' onClick='gridECFProperty_selectOnClick(this);' id='SelectProperty' value='#=PropertyID#'>#=PropertyID#</input>") cols.Bound(Function(it) it.PropertyName) cols.Bound(Function(it) it.CostSaving) cols.Bound(Function(it) it.ImplementationCost) cols.Bound(Function(it) it.TargetCompletionDate) cols.Bound(Function(it) it.ActualCompletionDate) End Sub ).Pageable().Scrollable().Sortable().Selectable().DataSource(Sub(d) d.Ajax().ServerOperation(True).Batch(True). Model(Sub(m) m.Id(Function(p) p.PropertyID)).PageSize(10). Read(Function(r) r.Action("ECFPropertyList", "ECFProperty", Request.RequestContext.RouteData.Values)). Update(Function(u) u.Action("SaveECFProperty1", "ECFProperty", Request.RequestContext.RouteData.Values)) ))<div> <input type="submit" id="submit" onclick="SaveECF();" value="Save ECF Property" /> </div>
function SaveECF() { $.ajax({ url: '@Url.Action("SaveECFProperty", "ECFProperty", Request.RequestContext.RouteData.Values)', type: 'POST', traditional: true, datatype: "json", data: { PropertyList: $("#ECFProperty").data("kendoGrid").dataSource.view().toJSON), currency:'USD' }, success: function () { window.alert('saved'); } }); }