簡體   English   中英

Kendo UI Listi View無法更新服務器上的數據

[英]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正確加載數據。 用戶編輯項目時,更改在本地可見(退出編輯模式后),並且按預期觸發了保存事件。

但是,更改永遠不會與服務器同步,永遠不會調用我的update方法,也永遠不會調用網絡活動。

ListView保存方法的文檔指出以下內容:

保存編輯的ListView項。 觸發保存事件。 如果不阻止保存事件並且驗證成功,將調用DataSource sync方法。

由於我不會在save事件上調用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
                    }
                }
            }
        }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM