1
在嘗試執行批量更新時,我無法將值發佈到MVC WEB API控制器,也無法獲得mu PUT控制器中的記錄ID。 我已經訪問了一些鏈接,可以解決同樣的問題,但沒有解決方案。在Kendo UI GRID中執行批量更新不起作用
$(document).ready(function() {
debugger;
var webapiUrl = (My webapi);
dataSource = new kendo.data.DataSource({
type: "json",
transport: {
read: {
url: webapiUrl + api/GetProductsByShipID/1",
contentType: "application/json",
},
update: {
url: webapiUrl + api/OpportunityProducts/1",
contentType: "application/json",
type: "PUT"
},
destroy: {
url: webapiUrl + /api/OpportunityProducts/",
contentType: "application/json",
type: "DELETE"
},
create: {
url: webapiUrl + /api/OpportunityProducts/",
contentType: "application/json",
type: "POST"
},
parameterMap: function (options, operation) {
if (operation !== "read") {
return options;
}
}
},
batch: true,
pageSize: 10,
schema: {
model: {
id: "ID",
fields: {
ID: { editable: false, nullable: true },
ProductDesc: { type: "string" },
Quantity: {type: "number"},
UnitPrice: { type: "number"}
}
}
});
$("#grid").kendoGrid({
dataSource: dataSource,
navigatable: true,
pageable: true,
toolbar: ["create", "save", "cancel"],
columns: [
"ProductName",
{ field: "ProductDesc", title: "Product Desc"},
{ field: "Quantity", title: "Quantity" },
{ field: "UnitPrice", width: 120 },
{ command: "destroy", title: " ", width:150 }],
editable: true
});
});
</script>
那麼,什麼是被髮送到你的API,當你檢查身體。使用像小提琴手一樣的東西。同樣在你的代碼示例中,它看起來像缺少圍繞'/ api/OpportunityProducts /' –
的開頭引用謝謝你的評論,下面是對這個問題的回答。在這裏複製網址時,報價錯誤是一個錯字。 –