Hello,
when using inline-edit in a grid with a datasource calling an OData v4 service, the deleted item is not substituted in the current page (see screen in attachment). What am I missing in my code?
Following an example
$(
'#gridProductCategories'
).kendoGrid({
sortable:
true
,
scrollable:
false
,
selectable:
true
,
pageable: {
refresh:
true
,
pageSizes: [5, 10, 20, 40],
buttonCount: 5
},
toolbar: [{ name:
"create"
, text: getLocValue(
"AddProductCategory"
) }],
editable: {
mode:
"inline"
,
confirmation: getLocValue(
"Confirmation"
)
},
columns: [
{
field:
"PC_ID"
,
title: getLocValue(
"ID"
)
},
{
field:
"PC_Text_de"
,
title: getLocValue(
"Text_de"
)
},
{
field:
"PC_Text_en"
,
title: getLocValue(
"Text_en"
)
},
{
width: 90,
command: [
{ name:
"edit"
, text: { edit:
""
, cancel:
""
, update:
""
}, className:
"action_button edit"
},
{ name:
"destroy"
, text:
""
, className:
"action_button delete"
}
],
title:
" "
}
]
});
[HttpDelete]
[EnableQuery(AllowedQueryOptions = AllowedQueryOptions.All)]
[Authorize(Roles =
"administrator, maintenance"
)]
public
IHttpActionResult Delete([FromODataUri]
int
key)
{
ProductCategory productCategory = dbcontext.ProductCategory.Find(key);
if
(productCategory ==
null
)
{
return
BadRequest(ModelState);
}
productCategory.PC_Deleted =
true
;
dbcontext.ProductCategory.AddOrUpdate(productCategory);
dbcontext.SaveChanges();
return
Ok(productCategory);
}
productCategorySource:
new
kendo.data.DataSource({
type:
"odata-v4"
,
pageSize: 20,
serverPaging:
true
,
serverFiltering:
true
,
serverSorting:
true
,
transport: {
read: {
url: serviceUrl +
"/odata/ProductCategories"
,
dataType:
"json"
,
type:
"GET"
},
update: {
url: serviceUrl +
"/odata/ProductCategories(0)"
,
dataType:
"json"
,
type:
"PUT"
},
create: {
url: serviceUrl +
"/odata/ProductCategories"
,
dataType:
"json"
,
type:
"POST"
},
destroy: {
url:
function
(data) {
return
serviceUrl +
"/odata/ProductCategories("
+ data.PC_ID +
")"
},
dataType:
"json"
,
type:
"DELETE"
}
},
schema: {
model: {
id:
"PC_ID"
,
fields: {
PC_ID: { type:
"number"
, editable:
false
},
PC_Text_de: { type:
"string"
, validation: { required:
true
} },
PC_Text_en: { type:
"string"
, validation: { required:
true
} }
}
}
},
error:
function
(e) {
console.log(e.errorThrown);
}
})