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

Data Source with Transport.Read function with local array behaves differently than with web service data.

3 Answers 428 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 26 Sep 2013, 07:11 PM
If I use the data from the web service, edit and save.. Everything works great. If I use the code below I get the following error:
Uncaught TypeError: Object #<Object> has no method 'call'
Full Error:
Uncaught 
TypeError: Object #<Object> has no method 'call'    kendo.all.js:5521
(anonymous function)   kendo.all.js:5521
jQuery.extend.Deferred   jquery-1.8.2.js:1182
Observable.extend._promise   kendo.all.js:5520
Observable.extend._send   kendo.all.js:5548
Observable.extend.sync   kendo.all.js:5384
Widget.extend.saveRow   kendo.all.js:16577
(anonymous function)   kendo.all.js:16399
jQuery.event.dispatch  jquery-1.8.2.js:3063
jQuery.event.add.elemData.handle.eventHandle   jquery-1.8.2.js:2681

following code:

    <script src="Scripts/KendoUI/jquery-1.8.2.js"></script>
    <script src="Scripts/KendoUI/kendo.all.js"></script>

$(document).ready(createkendo = function () {

var myData = [{"Id":1,"StudyName":"StudyName123","Subjid":"1","MatchId":"1","MatchSources":"1","ArgusCaseNum":"1","Field":"1","ArgusValue":"1","EdcValue":"1","ValuesMatch":"Y","Status":"1","DmComments":"comments, comments","PvComments":"333","DateCreated":"2013-09-26T06:57:07"},{"Id":2,"StudyName":"StudyName555","Subjid":"test","MatchId":"test","MatchSources":"test","ArgusCaseNum":"test","Field":"test","ArgusValue":"test","EdcValue":"test","ValuesMatch":"Y","Status":"test","DmComments":"asdfasdf","PvComments":"222","DateCreated":"0001-01-01T00:00:00"},{"Id":4,"StudyName":"asdfasdf","Subjid":"test","MatchId":"test","MatchSources":"test","ArgusCaseNum":"test","Field":"test","ArgusValue":"test","EdcValue":"test","ValuesMatch":"Y","Status":"test","DmComments":"asdf","PvComments":null,"DateCreated":"0001-01-01T00:00:00"}];
var crudServiceBaseUrl = "http://dev-webapp1.infinitypharm1.com/Argus.WebServices/api",
dataSource = new kendo.data.DataSource({
                            serverPaging: false,
                            serverFiltering: false,
                            serverSorting: false,
                            pageSize: 20,
                            schema: {
                                model: {
                                    id: "Id",
                                    fields: {
                                        StudyName: { type: "string" },
                                        DmComments: { type: "string" },
                                        PvComments: { type: "string" }
                                    }
                                }
                            },
                            batch: false,
                            transport: {
                                create: {
                                    url: crudServiceBaseUrl + "/argus",
                                    contentType: "application/json",
                                    type: "POST"
                                },
/*
                                read: {
                                    url: crudServiceBaseUrl + "/argus",
                                    contentType: "application/json",
                                    success: function(result) {
            options.success(result);
         }
                                },
                                */

read: function (options) {
options.success(localData); // where data is the local data array
},

update: {
                                    url: function (entity) {
                                        return crudServiceBaseUrl + "/argus/" + entity.Id;
                                    },
                                    contentType: "application/json",
                                    type: "PUT"
                                },
                                destroy: {
                                    url: function (entity) {
                                        return crudServiceBaseUrl + "/argus/" + entity.Id;
                                    },
                                    contentType: "application/json",
                                    type: "DELETE"
                                },
                                parameterMap: function (data, operation) {
                                    return JSON.stringify(data);
                                }
                            }
                        });

                    $("#grid").kendoGrid({
                        height: 600,
                        columns: [
                            { field: "StudyName", title: "Study Name" },
                            { field: "DmComments", title: "DM Comments" },
                            { field: "PvComments", title: "PV Comments" },
                            //{ command: "destroy", title: "Delete", width: "110px" }
                            { command: ["edit", "destroy"], title: "&nbsp;", width: "172px" }
                        ],
                        pageable: true,
                        sortable: true,
                        filterable: true,
                        editable: "inline", //true, // enable editing
                        //toolbar: ["create", "save", "cancel"], // specify toolbar commands
                        toolbar: ["create"],
dataSource: dataSource
                    });


});

3 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 27 Sep 2013, 08:40 AM
Hello Jeff,

DataSource transport should be consistent - if you use a custom transport for the read method, all other CRUD methods should be custom functions too. It is possible to issue Ajax request to the server from the custom transport function.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jeff
Top achievements
Rank 1
answered on 27 Sep 2013, 10:50 AM
I understand that it *should* work the same, but it's not working the same. What is the 'call' method that the error can't find. How do I sort it out?

Thanks,
Jeff
0
Alexander Valchev
Telerik team
answered on 30 Sep 2013, 12:27 PM
Hello Jeff,

I believe that there is a misunderstanding - if you use a custom transport for the read method, all other CRUD methods should be custom functions too. In other words:
transport: {
  read: function(options) { /* ... */ },
  create: function(options) { /* ... */ },
  update: function(options) { /* ... */ },
  destroy: function(options) { /* ... */ }
}

In order to sort out the error, please define all transport methods as functions.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Jeff
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Jeff
Top achievements
Rank 1
Share this question
or