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

grid Transport: pass just 1 param to Update (not the whole line)

2 Answers 97 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gaetano
Top achievements
Rank 1
Gaetano asked on 26 Jul 2013, 09:13 AM
Hi guys,
I'm working with a Read/Update trasport on kendo grid.
On Update I'd like to pass just 1 param to my server handler.

here is my grid:
$("#userGrid").data("kendoGrid").setDataSource(new kendo.data.DataSource({
            //data: userList,
            transport: {
                read: {
                    url: MyAxitea_Config.baseURL + "Services/UserHandler.ashx/GetUserListByCurrentUser",
                    type: "POST"
                },
                update: {
                    url: MyAxitea_Config.baseURL + "Services/UserHandler.ashx/UpdateUserAuthById",
                    dataType: "json",
                    type: "POST"/*,
                    data: function (options) {
                        return {
                            id: options.IdUtente,
                            abilitato: options.Abilitato
                        }
                    }*/
                }
            },
            schema: {
                model: {
                    id: "IdUtente",
                    fields: {
                        Nome: { type: "string", editable: false },
                        Cognome: { type: "string", editable: false },
                        Alias: { type: "string", editable: false },
                        IdPrivilegio: { type: "int", editable: false },
                        Email: { type: "string", editable: false },
                        Abilitato: { type: "boolean" },
                        DataDisattivazione: { type: "date", editable: false },
                    }
                }
            },
            pageSize: 10,
            sort: { field: "IdPrivilegio", dir: "asc" }
        }));
as you can see, in this case, only 1 param is editable ("Abilitato")
To update this field I only need tha updated value and the id.

With the current code, serverside, I get the whole line and since the object is quite big (for example it also contains a encoded string of the user picture),
I need to reduce the transported data.
Is that possible?


side question:
is it possible to implement transport only for update? using as dataSource a local list? I tried but I got only errors!
Thanks
Fabio! 

2 Answers, 1 is accepted

Sort by
0
Accepted
Petur Subev
Telerik team
answered on 30 Jul 2013, 06:30 AM
Hello Fabio,

Basically the whole model (with all of its fields) is send to the server.

You need to use the parameterMap function of the transport to change the format and which options are send to the server.

http://docs.kendoui.com/api/framework/datasource#configuration-transport.parameterMap

Regarding the second question, 

To have full control over the operations I would suggest you to specify the read/update as functions and perform whatever you want based on your needs.

Check the documentation for example:

http://jsbin.com/inebiw/1/edit


Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Gaetano
Top achievements
Rank 1
answered on 30 Jul 2013, 07:10 AM
Hi Petur,
Thanks for your answers!
Tags
Grid
Asked by
Gaetano
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Gaetano
Top achievements
Rank 1
Share this question
or