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

Inline editing, modify info using external button

2 Answers 195 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marcos
Top achievements
Rank 1
Marcos asked on 26 May 2015, 02:45 PM

Hello, I am using grid's inline editing mode and I have an external button that modifies some information on the rows. My problem is that after the information has been modified, if I click Edit and then Cancel, the row goes into its original state and I cannot find a way to persist this data. Does anyone know what could be wrong? Here is my code:

 This is what my button does:

 

01.function validateAll() {
02.        var grid = $("#Grid").data().kendoGrid;
03.        var orders = grid.dataSource.view();
04. 
05.        for (var i = 0; i < orders.length; ++i) {
06.            var order = orders[i];
07.            if (order.Status === 'Open') {
08.                order.Status = 'Valid'
09.            }
10.        }
11.        grid.refresh();
12.    }

 And this is the code of the grid:

 

01.@Code
02.    Dim grid = Html.Kendo().Grid(Of Model)()
03.    With grid
04.        .Name("Grid")
05.        .Editable(Sub(edit) edit.Mode(GridEditMode.InLine))
06.        .Columns(Sub(columns)
07.                         columns.Command(Sub(command)
08.                                                 command.Edit()
09.                                         End Sub)
10.                         columns.Bound(Function(c) c.Order)
11.                         columns.Bound(Function(c) c.Status)
12.                 End Sub)
13.        .DataSource(Sub(dataSource)
14.                            Dim dataSourceBuilder = dataSource.Ajax()
15.                            With dataSourceBuilder
16.                                .Read("GetGridData", "Order")
17.                                .Update("DummySave", "Order")
18.                                .Batch(True)
19.                                .ServerOperation(False)
20.                                .Model(Sub(model)
21.                                               model.Id(Function(row) row.Order)
22.                                       End Sub)
23.                            End With
24.                    End Sub)
25.    End With
26.End Code

2 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay Rusev
Telerik team
answered on 28 May 2015, 06:43 AM

Hello Marcos,

This behavior is expected. When cancel is clicked DataSource cancelChanges method is called with the current model. This method will revert back the model to its original state.

In order to persist the changes the model must be synced, i.e DataSource sync must be called. It will  send the model for updated on the server and the server must response the same way as if you click the save button inside the edit form.

Regards,
Nikolay Rusev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Marcos
Top achievements
Rank 1
answered on 28 May 2015, 09:03 AM
Thank you, this worked like a charm!
Tags
Grid
Asked by
Marcos
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Marcos
Top achievements
Rank 1
Share this question
or