Hi.
The REST-Api server is written with flask and python.
and Server's request parser require the following dictionary format asking PUT method.
{
"uuid": 15,
"subject": "newfile uploaded..",
"filepath": "newfile.zip",
"description": "ev3 install version : 1.4.1",
"count": 3
}
I've tested GET/POST/PUT/DEL method with POSTMAN and that's no problems.
However, When I ask PUT method using 'kendoui-gridedit-popup' there occurs some prolblems.
I've found the reason of it. That's the parameterMap's object and its format is not matched with my flask server's requirement.
when I request 'EDIT(PUT method)' with the kendoui library, the sending object's message is like the followings.
nodes: [{"count":1,"description":"ev3 install version : 1.4.1","filepath":"moba.zip","subject":"mobasss","uuid":3}]
Um...
I wish to convert the format matching with my server and I have to remove '[', ']' .
How can i do that? Let me know the solution.
$(document).ready(function () {
var crudServiceBaseUrl = "http://www.learnsteam.kr:5000",
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: crudServiceBaseUrl + "/nodes",
dataType: "json"
},
update: {
url: crudServiceBaseUrl + "/node/put",
dataType: "json",
type: "POST"
},
destroy: {
url: crudServiceBaseUrl + "/node/delete",
dataType: "json",
type: "POST"
},
create: {
url: crudServiceBaseUrl + "/node/post",
dataType: "json",
type: "POST"
},
parameterMap: function (options, operation) {
if (operation !== "read") {
console.log("Here parameterMap");
console.log(options);
return {nodes:kendo.stringify(options.models)};
//return json.stringify(options.models);
//msg==> nodes: [{"count":1,"description":"ev3 install version : 1.4.1","filepath":"moba.zip","subject":"mobasss","uuid":3}]
}
}
},
batch: true,
pageSize: 10,
schema: {
data: "nodes",
model: {
id: "uuid",
fields: {
uuid: { editable: false, nullable: true },
subject: { validation: { required: true } },
filepath: { type: "string", validation: { required: true } },
description: { type: "string" },
count: { type: "number", validation: { min: 1, required: true } }
}
}
}
});
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
height: 550,
toolbar: ["create"],
columns: [
{ field: "uuid", title: "ID", width: "120px" },
{ field: "subject", title: "제목", width: "400px" },
{ field: "filepath", title: "파일 경로", width: "400px" },
{ field: "description", width: "120px" },
{ field: "count", width: "100px" },
{ command: ["edit", "destroy"], title: " ", width: "250px" }],
editable: "popup"
});
});