2012-12-12 55 views
1

此代碼填充的DataGrid從收到的JSON格式化數據/ API /筆記/由龍捲風應用...kendogrid批量編輯追加行會導致數據發佈

$(document).ready(function() { 

    dataSource = new kendo.data.DataSource({ 
    pageSize: 10, 
    autoSync: true, 
    transport: { 
     read: { 
     url: '/api/notes/', 
     dataType: 'json', 
     type: 'GET' 
     }, 
     create: { 
     url: '/api/notes/', 
     dataType: 'json', 
     type: 'POST' 
     }, 
     update: { 
     url: '/api/notes/', 
     dataType: 'json', 
     type: 'PUT' 
     } 
    }, 
    schema: { 
     data: function(reply) { return reply.rows; }, 
     model: { 
     id: "id", 
     fields: { 
      id: { type: "string" }, 
      name: { type: "string" }, 
      author: { type: "string" }, 
     } 
     } 
    }, 
    }); 

    $("#grid").kendoGrid({ 
    dataSource: dataSource, 
    navigatable: true, 
    pageable: true, 
    height: 300, 
    editable: true, 
    toolbar: ["create", "save", "cancel"], 
    columns: [ 
     { field: "id", title: "ID", width: 150 }, 
     { field: "name", title: "Book", width: 150 }, 
     { field: "author", title: "Author", width: 100 }, 
     { command: "destroy", title: " ", width: 110 } 
    ], 
    }); 

}); 

如果我點擊創建,而不是彈出一個一行像here一個帖子引發空data參數,什麼是錯在這裏

回答

1

autoSync刪除或設置爲falseDataSource試試吧。根據文檔:

爲每次更改啓用(true)或禁用(false)sync()方法的自動調用。

所以我想當你嘗試插入行時,它立即把它放到數據源中,導致它做一個sync()。您鏈接到的演示版本也未指定autoSync