2012-12-12 31 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