Whenever I hit the "create" action on a Kendo Grid, it runs the same server side call for every item in the list that I created.
For example, I have three columns Increment/Range/SetId.
I add one item: 1/1/1
This calls my CreateItem method for the 1/1/1 item.
I add a second item: 2/2/1
This calls my Create Item method for the 1/1/1 item and the 2/2/1 item.
I now have items saved in my database as follows:
1/1/1
1/1/1 (Duplicate)
2/2/1
This pattern continues for as many items as I create. My Kendo code is as follows:
@(Html.Kendo().Grid<Model.IncrementSetItem>()
.Name("IncrementSetItemGrid")
.Columns(columns => {
columns.Bound(p => p.IncrementSetID);
columns.Bound(p => p.Increment).Width(140);
columns.Bound(p => p.RangeHigh).Width(140);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable()
.Sortable()
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.ID))
.Create(create => create.Action("CreateItem", "IncrementSet"))
.Read(read => read.Action("GetIncrementSetItemsList", "IncrementSet"))
.Update(update => update.Action("UpdateItem", "IncrementSet"))
.Destroy(destroy => destroy.Action("EditingInline_Destroy", "Grid"))
)
)
Please let me know if there is a way to have the "Create" event only act on just the last item that I have created inline.
For example, I have three columns Increment/Range/SetId.
I add one item: 1/1/1
This calls my CreateItem method for the 1/1/1 item.
I add a second item: 2/2/1
This calls my Create Item method for the 1/1/1 item and the 2/2/1 item.
I now have items saved in my database as follows:
1/1/1
1/1/1 (Duplicate)
2/2/1
This pattern continues for as many items as I create. My Kendo code is as follows:
@(Html.Kendo().Grid<Model.IncrementSetItem>()
.Name("IncrementSetItemGrid")
.Columns(columns => {
columns.Bound(p => p.IncrementSetID);
columns.Bound(p => p.Increment).Width(140);
columns.Bound(p => p.RangeHigh).Width(140);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable()
.Sortable()
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.ID))
.Create(create => create.Action("CreateItem", "IncrementSet"))
.Read(read => read.Action("GetIncrementSetItemsList", "IncrementSet"))
.Update(update => update.Action("UpdateItem", "IncrementSet"))
.Destroy(destroy => destroy.Action("EditingInline_Destroy", "Grid"))
)
)
Please let me know if there is a way to have the "Create" event only act on just the last item that I have created inline.