I have read all the Threads having this type of discussion based on that I gave Model Id as well. Aslo tried function for Edit and Delete URLs. but no luck.
This code was working earlier after that I added two more grid (which is commented right now) after that all Edit/Delete started coming as operation = create.
Here is the code.
<script>
$m = jQuery.noConflict();
</script>
$m("#siteInspectiongrid").kendoGrid({
dataSource: {
error: function (e) {
var msg = e.xhr.responseText;
var String = msg.substring(msg.lastIndexOf(":") + 1, msg.lastIndexOf(";"));
document.getElementById('errorMessage').innerText = String + "!!";
},
transport: {
read: {
url: crudServiceBaseUrl + "/SiteInspectionInfo?userGroup=" + userGroupConfiguration,
dataType: "json"
},
update: {
url: crudServiceBaseUrl + "/SiteInspectionInfo/Update?userGroup=" + userGroupConfiguration,
dataType: "json",
type: "PUT",
contentType: "application/json",
charset: "utf-8"
},
create: {
url: crudServiceBaseUrl + "/SiteInspectionInfo/Create?userGroup=" + userGroupConfiguration,
dataType: "json",
type: "POST",
contentType: "application/json",
charset: "utf-8"
},
destroy: {
url: crudServiceBaseUrl + "/SiteInspectionInfo/Delete?userGroup=" + userGroupConfiguration,
dataType: "json",
type: "DELETE",
contentType: "application/json",
charset: "utf-8"
},
parameterMap: function (options, operation) {
debugger;
if (operation !== "read" && operation !== "create" && options.models) {
return JSON.stringify({
'ReaderGroupID': options.models[0].ReaderGroupID,
'InspectionPercentage': options.models[0].InspectionPercentage,
'modifiedDate': options.models[0].modifiedDate,
'modifiedBy': options.models[0].modifiedBy,
'Active': options.models[0].Active,
'StaffType': options.models[0].StaffType,
'StaffTypeID': options.models[0].StaffTypeID
});
}
if (operation == "create" && options.models) {
return JSON.stringify({
'ReaderGroupID': options.models[0].readerGroupId.ReaderGroupID,
'InspectionPercentage': options.models[0].InspectionPercentage,
'createDate': options.models[0].createDate,
'createdBy': aliasName,
'modifiedDate': options.models[0].modifiedDate,
'modifiedBy': aliasName,
'StaffType': options.models[0].StaffId.StaffId,
'Active': options.models[0].Active
});
}
}
},
batch: true,
pageSize: 5,
schema: {
model: {
id: "Id",
fields: {
SiteCode: { editable: false, nullable: false },
SiteName: { editable: true, nullable: false },
ReaderGroup: { editable: true, nullable: false },
DoorRelay:{editable: true , nullable:false},
StaffType: { editable: true, nullable: false },
InspectionPercentage: { editable: true, nullable: true },
createdBy: { editable: false, nullable: true },
createDate: { editable: false, nullable: true },
modifiedBy: { editable: false, nullable: true },
modifiedDate: { editable: false, nullable: true },
Active: { editable: true, type: "boolean", defaultValue: true }
}
}
}
},
sortable: {
mode: "single",
allowUnsort: false
},
selectable: "multiple row",
pageable: {
buttonCount: 5
},
scrollable: false,
navigatable: true,
toolbar: [{ name: "create"
}],
edit: function (e) {
//======================================================
// Code to look for `hideMe` attribute on a column.
//======================================================
e.sender.columns.forEach(function (element, index /*, array */) {
if (element.hideMe) {
e.container.find(".k-edit-label:eq(" + index + "), "
+ ".k-edit-field:eq( " + index + ")"
).hide();
}
});
//======================================================
// End column hiding code
//======================================================
},
columns: [
{
field: "SiteCode",
title: "SiteCode",
hidden: true
},
{
field: "SiteName",
title: "SiteName"//,
// editor: siteDropDownEditor
},
{
field: "ReaderGroup",
title: "ReaderGroup"//,
//editor: readerGroupDropDownEditor//,
// template: '<a href="\\#" onclick="ReaderGroupDetails(#=ReaderGroupID# )">#=ReaderGroup#</a>'
},
{
field: "ReaderGroupID",
title: "ReaderGroupID",
hidden: true
},
{
field: "DoorRelay",
title: "DoorRelay",
hidden: true
},
{
field: "SearchRelay",
title: "SearchRelay",
hidden: true
},
{
field: "StaffType",
title: "StaffType"//,
// editor: staffDropDownEditor
}
,
{
field: "StaffTypeID",
title: "StaffTypeID",
hidden: true
}
,
{
field: "InspectionPercentage",
title: "Random %"
},
{
field: "createdBy",
title: "CreatedBy",
hideMe: true
}
,
{
field: "createDate",
title: "CreateDate",
hideMe: true
}
,
{
field: "modifiedBy",
title: "ModifiedBy",
hideMe: true
},
{
field: "modifiedDate",
title: "ModifiedDate",
hideMe: true
}
,
{ field: "Active", title: "Activated",
template: "<input type=\"checkbox\" #= Active ? checked='checked' : '' # class=\"check_row\"/>"
}
,
{ command: ["edit", "destroy"], title: "", width: 250 }
],
editable: {
mode: "inline"//,
// template: kendo.template($("#popup_editor").html())
}
});