How do you configure JayData to send POST/PUT instead of MERGE/PATCH
-
21-12-2019 - |
Question
I'm using a KendoUI grid to display some data. I'm using JayData to simplify the CRUD operations.
When I edit one item in a row and then click on update, it sends a MERGE Verb instead of POST.
Right now, I only want to send POST instead of MERGES.
How do I configure JayData to send PUTs and POSTs instead of MERGEs and PATCHes.
I don't think it matters, but below is my code:
var baseAssetMgmtURL = "http://localhost/AssetManagementAPI/odata/";
var crudServiceComputerBaseURL = baseAssetMgmtURL + "Computers/";
var computer = $data.define("computer", {
ComputerId: { type: Number, key: true },
AssetTag: Number,
BrandModel: String,
ComputerModelTypeId: Number,
ComputerTypeId: Number,
ComputerType: String,
PurchaseDate: Date,
OperatingSystemTypeId: Number,
OperatingSystemType: String,
ComputerName: String,
Notes: String,
MHIPSConnection: Date,
RetiredDate: Date
});
var ds = computer.asKendoDataSource({
provider: 'oData',
url: crudServiceComputerBaseURL,
batch: false,
pageSize: 10,
serverPaging: false
//,
//transport: { update: { type: "POST" } }
});
var setGrid = function () {
$("#grid").kendoGrid({
dataSource: ds,
columns: [
{ title: "AssetTag", field: "AssetTag", filterable: false },
{
title: "Brand Type", field: "ComputerModelTypeId", filterable: false,
editor: brandTypeDropDownEditor, template: "#= getModelType(ComputerModelTypeId) #"
},
{
title: "Computer Type", field: "ComputerTypeId", filterable: false,
editor: computerTypeDropDownEditor, template: "#= getComputerType(ComputerTypeId) #"
},
{ title: "PurchaseDate", field: "PurchaseDate", filterable: false },
{
title: "OS Type", field: "OperatingSystemTypeId", filterable: false,
editor: osTypeDropDownEditor, template: "#= getOSType(OperatingSystemTypeId) #"
},
{ title: "Name", field: "ComputerName", filterable: false },
{ title: "Notes", field: "Notes", filterable: false },
{ title: "MHIPSConnection", field: "MHIPSConnection", filterable: false },
{ title: "Retired", field: "RetiredDate", filterable: false },
{ command: ["edit"], title: " " }
],
pageable: true,
sortable: false,
scrollable: false,
editable: "inline",
toolbar: ["create"]
});
};
Solution
You can rewrite the http verb to put/post but the body of the request would still be a merge request, you can find examples about rewriting here: https://github.com/jaydata/jaydata/issues/111
if you want REST then use the webapi provider
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow