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

kendo grid update

1 Answer 115 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Phani
Top achievements
Rank 1
Phani asked on 09 Jun 2015, 08:57 PM

Hello, i'm unable to get the jquery grid to update using a webservice method, i'm running into Uncaught TypeError: Cannot read property 'call' of undefined - kendo.web.min.js:13. Here is how my grid and update method are defined. Could someone please point me in the right direction. Thanks!

 

var grid = $("#StatusGrid").kendoGrid({
                   dataSource: {
                       transport: {
                           read: function (options) {
                               $.ajax({
                                   type: "POST",
                                   url: "StatusDetailsWS.asmx/GetStatusesJSON",
                                   data: jsonReqID,
                                   contentType: "application/json; charset=utf-8",
                                   dataType: "json",
                                   dataFilter: function (data) {
                                       //debugger;
                                       var msg = eval('(' + data + ')');
 
                                       // If the response has a ".d" top-level property,
                                       //  return what's below that instead.
                                       if (msg.hasOwnProperty('d'))
                                           return msg.d;
                                       else
                                           return msg;
                                   },
                                   success: function (msg) {
                                       if (msg && msg.Success == false) {
                                           // ToDo: Add Kendo Window dialog to
                                           //Show Error
                                       }
                                       if (msg && msg.Success) {
                                           // redirect to New Job
                                           var data = eval('(' + msg.ReturnValue + ')');
                                           options.success(data);
                                       }
                                   },
                                   error: function (jqXHR, textStatus, errorThrown) {
                                       options.error(jqXHR);
                                       //alert("error");
                                   }
                               });
                           },
                           update: {
                               type: "POST",
                               url: "StatusDetailsWS.asmx/UpdateStatusJSON",
                               dataType:"json",
                               contentType: "application/json"
                           },
                           parameterMap: function (data, operation) {
                               if (operation === "update" || operation === "create") {
                                   return JSON.stringify({ job : data });
                               }
                               return data;
                           }
                            
                       },
                       schema: {
                           data: "Data",
                           total: "Total",
                           model: {
                               fields: {
                                   jobNumber: { type: "number", editable:false },
                                   parentStatus: { type: "string", editable:false },
                                   childStatus: { type: "string", editable:false },
                                   submitDate: { type: "date", editable:false },
                                   userId: { type: "string", editable:false },
                                   notes: { type: "string" }
                               }
                           }
                       },
                       pageSize: 25,
                       serverPaging: false,
                       serverFiltering: false,
                       serverSorting: false
                   },
                   height: 300,
                   filterable: false,
                   sortable: true,
                   pageable: true,
                   columns: [{
                       field: "jobNumber",
                       title: "Job #",
                       width: 55,
                       editable:false,
                       template: "<a href='javascript:openJobStatus("#: data.jobNumber #");'>#: data.jobNumber #</a>"
                   },
                   {
                       field: "parentStatus",
                       title: "Overall Status",
                       editable:false,
                       width: 70
                   },
                   {
                       field: "childStatus",
                       title: "Current Status",
                       editable:false,
                       width: 70
                   },
                   {
                       field: "submitDate",
                       title: "Submit Date",
                       width: 95,
                       editable:false,
                       format: "{0:MM/dd/yyyy h:mm:ss tt}"
                   },
                   {
                       field: "userId",
                       title: "Submitter",
                       editable:false,
                       width: 60
                   },
                   {
                       field: "notes",
                       title: "Notes",
                       width: 180
                   },
                   {
                       command:[{
                           id:"edit",
                           name:"edit",
                           template: "<a class='k-button k-grid-edit' href='' style='min-width:16px;'><span class='k-icon k-edit'></span></a>"
                       }
                       ],
                       title:"",
                       width:"20px"
                   },
                   //{
                   //    title: "",
                   //    template: "<a href='javascript:openJobStatus(\"#:jobNumber#\");'><img src='images/edit_m.png' alt='Edit Job' style='border:0;' /></a>",
                   //    width: 20
                   //},
                   {
                       title: "",
                       template: "<input type='image' alt='submit' title='Print Job' src='images/print_m.png' id='btnPrintJob' onclick='openPrintJobWindow(\"#:jobNumber#\");' style='border:0;' />",
                       width: 20
                   },
                   {
                       title: "",
                       template: "<input type='image' alt='submit' title='Restore Request' src='images/wrench_m.png' id='btnRestoreRequest' onclick='restoreRequest(\"#:jobNumber#\");' style='border:0;' />",
                       //hidden: !CanRestoreRequest,
                       width: 20
                   },
                   {
                       title: "",
                       template: "<input type='image' alt='submit' title='Copy Request' src='images/copy_m.png' id='btnCopyRequest' onclick='copyRequest(\"#:jobNumber#\");' style='border:0;' />",
                       width: 20
                   }
                   ],
                   editable:"inline"
                   
                   
               });

[WebMethod(true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public void UpdateStatusJSON(string job)
        {
           ...
....
 
        }

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 11 Jun 2015, 11:19 AM
Hi Phani,

DataSource transport methods should be of same type - e.g. if the read method is defined as a custom function, the create/update and destroy methods should be also custom functions.

This is the reason of the JavaScript error that you receive.

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
Phani
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or