Hi There,
I am working on a grid which has a dropdownlist column. I use the solution in the following demo:
https://demos.telerik.com/aspnet-core/grid/editing-custom
The difference is that we need to save the grid through an ajax call instead of the build-in "Save Changes" button. I added a "Save" button under the grid, change the dropdownlist value and use the following code to post the grid data to Controller action, but the value of products passed to Action always contains the original dropdownlist value other than the updated value. Is there anything not right in my code? Please help. Thank you.
$('#btnSaveGridData').click(function () {
var data = $("#grid").data("kendoGrid").dataSource.data();
$.ajax({
url: '/Editing_CustomController/SaveGridData',
type: "post",
contentType: 'application/json',
dataType: 'json',
data: JSON.stringify(data),
complete: function (response) {
$("#gridSection").empty();
$("#gridSection").html(response.responseText);
},
failure: function (response) {
//alert(response.responseText);
},
error: function (response) {
//alert(response.responseText);
}
});
});
Controller Action
[HttpPost]
public async Task<
IActionResult
> SaveGridData([FromBody] List<
ProductViewModel
> products)
{
//Action logic
return PartialView("_Grid");
}