How to dynamically change the values in the kendo ui grid

jquery, kendo-grid, kendo-ui

Solution

If you want to play with the data directly you need to mark the records you changes as dirty.

 dataSource.data()[changedIndex].dirty = true;
 dataSource.sync();

Problem

I am using the kendo ui grid. In that i have used the batch mode to save the values. If i change the record in one row then the value with the corresponding row also will be changed and when we click on the save then both the fields will be saved to the database. For eg. I am having a grid like: ``` Integer Value 1 First 2 Second 3 Third 4 Fourth ``` If i change the value of 1 to 4 then the 4 will be changed and the values also changed dynamically. What i mean is i want to interchange 1 and 4 here. And also i can change remaining all fields also but finally all the records must be saved to the database. I have tried like This code will be in the grid change function ``` var grid = $('#grid').data("kendoGrid"); var selectedRow = grid.select(); var selectedRowIndex = selectedRow.index(); console.log(selectedRowIndex); var firstItem = dataSource.data()[selectedRowIndex]; var datalength = dataSource.data(); for (var i = 0; i < datalength.length; i++) { var dataItem = datalength[i].id; if (dataItem == firstItem.get('id')) { var secondItem = dataSource.data()[i]; secondItem.set('id', dataItem); } } ``` Then the values are changing but the values are not passing to the controller after it has been changing.

Original source

Related problems