Hi Bernard,
Thanks for contacting Syncfusion Support.
Query#:- Why the CRUD from the grid is not working after I set datasource from the code?
We have checked your code example and we can reproduce the problem from your code. While on analyzing further you have updated the dataSource using dataSource method. When we update using dataSource method, it will behaves like Local Data and we couldn’t perform CRUD operations on this.
While using remoteSaveAdaptor, dataSource has been updated on model.dataSource.dataSource.json. So we suggest you to update the dataSource on model.dataSource.dataSource.json and refresh the Grid using refreshContent method
Refer to the modified code example:-
function onGodinaChange(args) {
var god = $("#cboxGodina").val();
var obj = $("#gridPlan").data("ejGrid");
var src = '@Url.Action("Data", "Grid", new { area = "" })';
$.ajax({
cache: false,
url: src,
data: { "Godina": god },
type: "get"
}).done(function (data) {
obj.model.dataSource.dataSource.json = ej.parseJSON(Data);
obj.refreshContent();
}).fail(function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
alert("fail");
});
} |
Refer to the API Link:-
Please get back to us if you need any further assistance.
Regards,
Farveen sulthana T