This is a migrated thread and some comments may be shown as answers.

Is it possible parameterMap format converting?

1 Answer 161 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ATO
Top achievements
Rank 1
ATO asked on 29 Jun 2018, 03:59 AM

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"
                });
            });

 

 

 

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 02 Jul 2018, 06:02 AM
Hello, Ato,

Thank you for the details.

Please have in mind that the Grid will automatically send the request in the shown format if the batch option is not set:

https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/configuration/batch

As the editing type is popup the batch option is not needed.

Please check if removing the batch and parameter map options will resolve the issue.

Also, please request type can set to "PUT" if the server expects PUT requests:

https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/configuration/transport.create#transport.create.type

I hope this is helpful.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
ATO
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or