Kendo UI 列表视图未更新服务器上的数据

Kendo UI Listi View not updating data on the server

我在使用 Kendo UI Listview 将更改保存到服务器时遇到问题。

数据源配置如下:

var listViewDataSource = new kendo.data.DataSource({
        transport: {
            read: {
                url: MyServiceURL
            },
            update: function() {
                console.log("test"); // I expected to enter this function 
                                     //  when the user changes data on the 
                                     //client, never happens
            }
        },
        schema: {
            Id: "Id",
            fields: {
                DeptName: {
                    editable: false,
                },
                HourRate: {
                    type: "number",
                    editable: true
                },
                ShowOnSavings: {
                    type: "boolean",
                    editable: true
                },
                ShowOnTechnicalCosts: {
                    type: "boolean",
                    editable: true
                },
                ShowOnOtherCosts: {
                    type: "boolean",
                    editable: true
                }
            }
        },
        sync: function (e) {
            console.log("item synched"); //This should be fired after the 
                                         // updated data is sent, never 
                                         //happens   
        }

ListView 初始化如下:

kendo.bind($("#listview-container"), {
        listViewDataSource: listViewDataSource,
        onItemSaved: function (e) {
            console.log("item saved"); // fired every time the user changes 
                                      //an item, as expected 
        }
    })

ListView 正确加载数据。当用户编辑一个项目时,更改在本地可见(离开编辑模式后)并且保存事件被触发,如预期的那样。

然而,更改永远不会与服务器同步,我的更新方法永远不会被调用,网络 activity 也永远不会被调用。

有关 ListView 保存方法的文档说明如下:

Saves edited ListView item. Triggers save event. If save event is not prevented and validation succeeds will call DataSource sync method.

因为我没有在保存事件上调用 preventDefault,所以我希望数据源能够同步,但是这并没有发生。手动调用 dataSource.sync() 也无济于事。

我很困惑为什么这不起作用。任何提示表示赞赏。

我在模型配置中跳过了一层嵌套,缺少 模型

schema: {
            model: {
                id: "Id",
                fields: {
                    Id: {
                        type: "number",
                        editable: false
                    },
                    DeptName: {
                        type: "string",
                        editable: false
                    },
                    HourRate: {
                        type: "number",
                        editable: true
                    },
                    ShowOnSavings: {
                        type: "boolean",
                        editable: true
                    },
                    ShowOnTechnicalCosts: {
                        type: "boolean",
                        editable: true
                    },
                    ShowOnOtherCosts: {
                        type: "boolean",
                        editable: true
                    }
                }
            }
        }