This is a migrated thread and some comments may be shown as answers.

Kendo Grid - Inline Editing Problem With Creating Items

1 Answer 462 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 25 Sep 2012, 06:09 PM
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.

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 28 Sep 2012, 12:38 PM
Hello Steven,

I believe that the problem you experienced is caused by a not updated or duplicated record IDs. By default records with ID equal to 0 (that is the default value) are considered as new (not inserted) and the Grid will continue to send to the server via create requests.
For more information on this subject as well as tips how to solve it please check the following forum posts:
I hope this information will help.

Regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Steven
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or