page:
var dataSource = new kendo.data.DataSource({
type: "aspnetmvc-ajax",
pageSize: 25000,
serverPaging: false,
serverGrouping: false,
transport: {
read: {
url: urlRead,
data: kendo.antiForgeryTokens(),
type:"GET"
},
create: {
url: urlCreate,
data: kendo.antiForgeryTokens(),
cache: true,
},
update: {
url: urlUpdate,
data: kendo.antiForgeryTokens(),
cache: true,
},
destroy: {
url: urlDestroy,
data: kendo.antiForgeryTokens(),
cache: true
},
parameterMap: function (data, type) {
//if (type == "create") {
// // send the created data items as the "models" service parameter encoded in JSON
// return { models: kendo.stringify(data.models) };
//}
}
},
//requestStart: function() {
// kendo.ui.progress($("#"+gridName), true);
//},
//requestEnd: function() {
// kendo.ui.progress($("#"+gridName), false);
//},
sync: function (e) {
},
schema: {
data: "Data",
total: "Total",
errors: "Errors",
model: model,
errors: function (response) {
//ShowNotification(response);
return response.error;
}
},
error: function (e) {
//ShowNotification("Error");
dataSource.cancelChanges();
}
});
//dataSource.bind("error", function () { ShowNotification("dsError") });
grid.setOptions({
dataSource: dataSource,
persistSelection: true,
navigatable: true,
resizable:true,
reorderable:true,
dataBound: function (e) {
if (e.sender.dataSource.view().length > 0) {
e.sender.select("tr:eq(0)");
grid.trigger("change");
grid.unbind("dataBound");
}
}
});
backend: Controller
[HttpPost("AddCoatingType")]public ActionResult AddCoatingType(CoatingAgentType item,[DataSourceRequest] DataSourceRequest request )
{
try
{
//var experimentItemsView = ApplicationHelper.GetExperimentitems(AppConstant.ISTA, _ipConfig);
//_coatingAgentTypeRepository.Insert(coatingAgentType);
//await _coatingAgentTypeRepository.SaveAsync();
//return new JsonResult(new[] { coatingAgentType }.ToDataSourceResult(request, ModelState));
return new JsonResult("OK");
}
catch (Exception ex)
{
return this.StatusCode(StatusCodes.Status500InternalServerError, $"Error Info: {ex.Message}");
}
}