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

update function of transport object never called

1 Answer 152 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Johan
Top achievements
Rank 1
Johan asked on 29 Oct 2012, 07:09 PM
Hi,

I created a datasource and attached the datasource to the Grid. The datasource contains functions for the transport object. When I change a value in my grid, I would expect that the update function is called when I click the Save button in the toolbar. But the update function is not called. Instead for each item in the grid the create function is called.

Code:
                $(document).ready(function() {
var data = createRandomData(2);

                    $("#grid").kendoGrid({
                        dataSource: {                            
                            schema: {
                                model: {
Id: "Id",
                                    fields: {
Id: { type: "number" },
                                        FirstName: { type: "string" },
                                        LastName: { type: "string" },
                                        City: { type: "string" },
                                        Title: { type: "string" },
                                        BirthDate: { type: "date" },
                                        Age: { type: "number" }
                                    }
                                }
                            },
                            pageSize: 10,
transport: {
read: function(options) {
//alert('read');
 //var result = createRandomData(50);
 options.success(data);  
},
create: function(options) {
   alert('create');
 //var result = getResult(options);
 options.success(data);
},
update: function(options) {
alert('update');
 //var result = getResult(options);
 options.success(data);
},
destroy: function(options) {
alert('destroy');
 //var result = getResult(options);
 options.success(data);
},
parameterMap: function(options, operation) {
alert('map');
                                    if (operation !== "read" && options.models) {
                                        //return {models: kendo.stringify(options.models)};
                                    }
                                }
 }
                        },
toolbar: ["create", "save", "cancel"],
                        height: 250,
                        scrollable: true,
                        sortable: true,
                        filterable: true,
                        pageable: true,
editable: true,
batch: false,
                        columns: [
                            {
                                field: "FirstName",
                                title: "First Name",
                                width: 100
                            },
                            {
                                field: "LastName",
                                title: "Last Name",
                                width: 100
                            },
                            {
                                field: "City",
                                width: 100
                            },
                            {
                                field: "Title"
                            },
                            {
                                field: "BirthDate",
                                title: "Birth Date",
                                template: '#= kendo.toString(BirthDate,"MM/dd/yyyy") #'
                            },
                            {
                                field: "Age",
                                width: 50
                            },
{ command: "destroy", title: " ", width: "110px" }
                        ]
                    });
                });

1 Answer, 1 is accepted

Sort by
0
Johan
Top achievements
Rank 1
answered on 30 Oct 2012, 08:23 AM
I found the problem myself; the id property in the Model should be all lower-case.
Tags
Grid
Asked by
Johan
Top achievements
Rank 1
Answers by
Johan
Top achievements
Rank 1
Share this question
or