Hi,
I am trying to update Kendo Grid row inline, but getting a bad request when doing so.
Reading from the list work just fine, but I am not able to update.
Any ideas?
var
dataSource =
new
kendo.data.DataSource({
transport: {
read: {
url: crudServiceBaseUrl +
"?$top=2000"
,
type:
"GET"
,
dataType:
"json"
,
contentType:
"application/json;odata=verbose"
,
headers: {
"accept"
:
"application/json;odata=verbose"
}
},
// ...
update: {
url:
function
(data) {
return
crudServiceBaseUrl +
"("
+ data.ID +
")"
;
},
type:
"POST"
,
dataType:
"json"
,
data: JSON.stringify({
"__metadata"
: { type:
"SP.Data.MasterListItem"
}
}),
contentType:
"application/json;odata=verbose"
,
headers: {
"accept"
:
"application/json;odata=verbose"
,
"X-RequestDigest"
: $(
"#__REQUESTDIGEST"
).val(),
"X-HTTP-Method"
:
"MERGE"
},
},
//...
parameterMap:
function
(data, type) {
if
(type ==
"update"
) {
for
(
var
property
in
data) {
if
(property !=
"__metadata"
)
delete
data[property];
}
}
return
JSON.stringify(data);
}
},
error:
function
(e, data) {
console.log(
"Status: "
+ e.status +
"; Error message: "
+ e.errorThrown );
},
pageSize: 15,
schema: {
data:
function
(data) {
return
data.d && data.d.results;
},
total:
function
(data) {
return
data.d.results.length;
},
model: {
id:
"Id"
,
fields: {
Id: { type:
"number"
, editable:
false
, nullable:
false
},
Title: { type:
"string"
, validation: { required:
true
} },
OWNER: { type:
"string"
, validation: { required:
false
} }
}
}
},
//batch: false,
//serverPaging: true,
sort: { field:
"OWNER"
, dir:
"desc"
}
});