I am currently using the open source edition of Kendo Web with the Kendo UI Web on ASP.NET MVC 4. My Kendo grid contains the following JavaScript code:
<script>
$(document).ready(function () {
$("#grid").kendoGrid({
dataSource: {
type: "odata",
serverSorting: true,
serverFiltering: true,
serverPaging: true,
transport: {
read: {
url: "api/Usermanage",
dataType: "json",
contentType: "application/json"
},
create: {
url: "/api/Usermanage",
dataType: "json",
type: "POST"
},
update: {
url: function (UserModel) {
return "/api/articles/" + UserModel.ID
},
dataType: "json",
type: "PUT"
},
destroy: {
url: function (UserModel) {
return "/api/Usermanage/" + UserModel.ID
},
dataType: "json",
contentType: "application/json",
type: "DELETE"
},
parameterMap: function(options, operation) {
if (operation !== "read" && options.models) {
return {models: kendo.stringify(options.models)};
}
}
},
schema: {
data: function (response) {
if (response.value !== undefined)
return response.value;
else {
delete response["odata.metadata"];
return response;
}
},
total: function (response) {
return response['odata.count'];
},
model: {
fields: {
ID:"ID",
ID: { editable: false },
Name: { type: "string", editable: true, nullable: false, validation: { required: true } },
Roles: { type: "string" }
}
}
}
},
height: 430,
scrollable: {
virtual: true
},
toolbar: ["create"],
editable: "popup",
sortable: true,
columns: [
{ field: "Name", title: "UserName", width: 110 },
{ field: "Roles", title: "Role", width: 160 },
{ command: ["edit", "destroy"], title: " ", width: "160px" }
]
});
});
</script>
The method in the API controller is as follows:
// DELETE api/usermanage/5
public void Delete(int id)
{
var name = db.UserProfiles.Find(id);
Membership.DeleteUser(name.UserName,true);
}
However, I am facing an issue with this implementation. Can someone please guide me on what I might be doing wrong?