2013-08-16 50 views
5

當我點擊更新按鈕彈出kendo網格時,這個錯誤是怎麼回事?語法錯誤:缺少;在kendoui之前的聲明

  • 火狐瀏覽器的錯誤是在這種形式:SyntaxError: missing ; before d.0=value

  • 的Chrome瀏覽器Uncaught SyntaxError: Unexpected number

我上傳關於這個錯誤的視頻詳細說明n東西

Jsfiddle Code

Video

代碼

transport: { 
    read: { 
     url: 'https://dl.dropboxusercontent.com/sh/u9oxg5f6uweqh40/CbR3pNVg04/documentj', 
     dataType: 'json', 
     type: 'get', 
     cache: false 
     }, 
    update: function(e) { return true; } 
} 
save: function (e) { 
    var that = this; 
    $.ajax({ 
     url: '/echo/json', 
     type: e.model.id == null ? 'POST' : 'PUT', 
     contentType: 'application/json', 
     dataType: 'json', 
     data: JSON.stringify(e.model), 
     success: function (data) { 
      // Alertify.log.success(data); 
      console.log('ok dadasaved'); 
      that.refresh(); 
     }, 
     error: function (data) { 
      // Alertify.log.error(data); 
      console.log('no datasaved'); 
      that.cancelRow(); 
     } 
    }); 
} 
+0

您需要至少在transport.update定義中調用options.success。在文檔中有一個工作示例:http://docs.kendoui.c​​om/api/framework/datasource#configuration-transport.update –

+0

在您JSFiddle中單擊「整理」按鈕並再次運行它 – OnaBai

+0

我點擊了一個「整理」 –

回答

2

你應該提供更多的代碼來檢測一下是你的代碼錯誤,但讀this可以幫助你:

Such error occurs when the transport definitions are inconsistent. In other words, if you would like to use custom transport method, all transport types should be defined as functions.

Having a standard read transport and custom update is not supported. Please configure all transports as functions and let me know if the error still occurs.

1

我有同樣的錯誤和對我來說,問題是,dataType選項沒有爲所有transport方法設置。我用下面的註釋標記該行:

var linksDataSource = new kendo.data.DataSource({ 
    transport: { 
     read: { 
      dataType: "json", 
      url: 'read-url', 
      type: "get" 
     }, 
     destroy: { 
      dataType: "json", /* <============ THIS LINE WAS MISSING */ 
      url: 'delete-url', 
      type: "delete" 
     }, 
     update: { 
      dataType: "json", 
      url: 'update-url', 
      type: "post" 
     }, 
     create: { 
      dataType: "json", 
      url: 'create-url', 
      type: "post", 
      complete: function() { 
       $("#searchResult").data("kendoGrid").dataSource.read(); 
      } 
     }, 
/* ... */ 
+0

這是我的問題。謝謝 – Quiver

相關問題