Is it possible parameterMap format converting?

2 posts, 0 answers
  1. ATO
    ATO avatar
    2 posts
    Member since:
    May 2018

    Posted 28 Jun 2018 Link to this post

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

     

     

     

  2. Stefan
    Admin
    Stefan avatar
    3008 posts

    Posted 02 Jul 2018 Link to this post

    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.
Back to Top