Come si configura JayData per inviare post / mettere invece di unire / patch
-
21-12-2019 - |
Domanda
Sto usando una griglia Kendoui per visualizzare alcuni dati.Sto usando JayData per semplificare le operazioni Crud.
Quando modifico un elemento in una riga e quindi fare clic su Aggiornamento, invia un verbo di unione anziché post.
In questo momento, voglio solo inviare post invece di focali.
Come posso configurare JayData per inviare messaggi e messaggi invece di focali e patch.
Non penso che sia importante, ma sotto è il mio codice:
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"]
});
.
};
Soluzione
È possibile riscrivere il verbo http per inserire / pubblicare ma il corpo della richiesta sarebbe comunque una richiesta di unione, è possibile trovare esempi sulla riscrittura qui: https://github.com/jaydata/jaydata/issues/111
Se si desidera riposo, utilizzare il provider di wibapi