Hi i am using kendo grid in my page defined in javascript. Below is my grid code in javascript
function LoadAllPanelUsers() {
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "/Home/LoadAllUsers",
type: "POST",
dataType: "json"
},
update: {
url: "/Home/UpdateUser",
dataType: "json",
type: "POST"
},
destroy: {
url: "/Home/DeleteUser",
dataType: "json",
type: "POST"
},
create: {
url: "/Account/InsertUser",
dataType: "json",
type: "POST"
},
parameterMap: function (options, operation) {
if (operation !== "read" && options.models[0]) {
return options.models[0];
}
}
},
type: "json",
batch: true,
schema: {
model: {
id: "UserID",
fields: {
UserID: { editable: false, nullable: true, type: "number" },
UserNumber: { type: "number", validation: { required: true, max: 96} },
UserDescription: { type: "string", validation: { maxLength: 31} },
PartitionNumber: { editable: false, type: "number", defaultValue: "1", validation: { required: true} },
AuthorityLevel: { type: "number", validation: { required: true }, defaultValue: 0 },
UserCode: { type: "number", validation: { required: true, maxLength: 4, minLength: 4} },
IsDeleted: { type: "bool" },
IsEnabled: { type: "bool" }
}
},
data: "data",
total: "total"
}
});
var PanelDevices = [];
$("#rdgrd_AIB_UserResults").empty();
$("#rdgrd_AIB_UserResults").kendoGrid({
dataSource: dataSource,
height: 410,
selectable: "row",
toolbar: ["create", "save", "cancel"],
columns: [
{
field: "UserNumber",
title: "User Number",
width: 150
},
{
field: "UserDescription",
title: "User Name",
width: 150
},
{
field: "PartitionNumber",
title: "Partition Number",
width: 150
},
{
field: "UserCode",
title: "User Code",
width: 150
},
{
field: "AuthorityLevel",
title: "Authority Level",
width: 150
}
],
editable: true,
navigatable: true
});
}
when i insert the row , enter necessary values and click on save changes the controller action is called and the user is created in DB successfully. i return the same object after updating the new user id to the grid. below is my response body recieved from controller action.
{"ExtensionData":null,"AuthorityLevel":3,"Changed":false,"ChangedBy":null,"Defaulted":false,"IsDeleted":false, "IsEnabled":false,"MacPanelID":0,"PartitionNumber":1,"SortIndex":null,"UserCode":"5428","UserDescription":"test234", "UserID":66,"UserNumber":43} in the response data you can see that the user id is 66. this id is not getting updated in the grid data. following is my grid data after save changes
function LoadAllPanelUsers() {
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "/Home/LoadAllUsers",
type: "POST",
dataType: "json"
},
update: {
url: "/Home/UpdateUser",
dataType: "json",
type: "POST"
},
destroy: {
url: "/Home/DeleteUser",
dataType: "json",
type: "POST"
},
create: {
url: "/Account/InsertUser",
dataType: "json",
type: "POST"
},
parameterMap: function (options, operation) {
if (operation !== "read" && options.models[0]) {
return options.models[0];
}
}
},
type: "json",
batch: true,
schema: {
model: {
id: "UserID",
fields: {
UserID: { editable: false, nullable: true, type: "number" },
UserNumber: { type: "number", validation: { required: true, max: 96} },
UserDescription: { type: "string", validation: { maxLength: 31} },
PartitionNumber: { editable: false, type: "number", defaultValue: "1", validation: { required: true} },
AuthorityLevel: { type: "number", validation: { required: true }, defaultValue: 0 },
UserCode: { type: "number", validation: { required: true, maxLength: 4, minLength: 4} },
IsDeleted: { type: "bool" },
IsEnabled: { type: "bool" }
}
},
data: "data",
total: "total"
}
});
var PanelDevices = [];
$("#rdgrd_AIB_UserResults").empty();
$("#rdgrd_AIB_UserResults").kendoGrid({
dataSource: dataSource,
height: 410,
selectable: "row",
toolbar: ["create", "save", "cancel"],
columns: [
{
field: "UserNumber",
title: "User Number",
width: 150
},
{
field: "UserDescription",
title: "User Name",
width: 150
},
{
field: "PartitionNumber",
title: "Partition Number",
width: 150
},
{
field: "UserCode",
title: "User Code",
width: 150
},
{
field: "AuthorityLevel",
title: "Authority Level",
width: 150
}
],
editable: true,
navigatable: true
});
}
when i insert the row , enter necessary values and click on save changes the controller action is called and the user is created in DB successfully. i return the same object after updating the new user id to the grid. below is my response body recieved from controller action.
-
Request URL:http://localhost:60410/Account/InsertPanelUser
-
Request Method:POST
-
Status Code:200 OK
{"ExtensionData":null,"AuthorityLevel":3,"Changed":false,"ChangedBy":null,"Defaulted":false,"IsDeleted":false, "IsEnabled":false,"MacPanelID":0,"PartitionNumber":1,"SortIndex":null,"UserCode":"5428","UserDescription":"test234", "UserID":66,"UserNumber":43} in the response data you can see that the user id is 66. this id is not getting updated in the grid data. following is my grid data after save changes
here in the above object you can see that id and userid is null