Kendo UI网格节省细胞模糊

imp*_*335 6 javascript jquery json gridview kendo-ui

当我按下Enter或移出单元格(模糊)时,我试图让我的网格保存更改,而不必使用网格工具栏中的保存按钮.

我无法正常工作,我的PHP/SQL工作正常,所以我确定网格有问题.

这是我的代码:

$("#grid").kendoGrid({
dataSource: {
    transport: {
        read: WEBROOT+"admin/fetch-toppers",
        update: {
            url: WEBROOT+"admin/update-topper",
            type: "POST"
        }
    },
    error: function(e)
    {
        alert(e.responseText);
    },
    schema: {
        data: "data",
        model: {
            id: 'id',
            fields: {
                "id": {nullable: true},
                "Date": {editable: false},
                "name": {editable: false},
                "price": {editable: true}
            }
        }
    }
},
columns: [{field: "Date", width: 105}, {field: "name", title: "Topper"}, {field: "price", title: "Price", width: 125}],
height: 550,
filterable: true,
sortable: true,
pageable: true,
editable: true,
navigatable: true,
edit: function()
{
    //this.saveChanges()
}
});
Run Code Online (Sandbox Code Playgroud)

我尝试了许多事情和不同的事件,但没有效果.

如何在模糊时保存单元格值?

Rod*_*ney 7

在您的DataSource中添加:

change: function (e) {
                        if (e.action == "itemchange") {
                            this.sync();
                        }
                    },
Run Code Online (Sandbox Code Playgroud)

它应该看起来像:

dataSource: {
transport: {
    read: WEBROOT+"admin/fetch-toppers",
    update: {
        url: WEBROOT+"admin/update-topper",
        type: "POST"
    }
},
error: function(e)
{
    alert(e.responseText);
},
change: function (e) {
                        if (e.action == "itemchange") {
                            this.sync();
                        }
},
schema: {
    data: "data",
    model: {
        id: 'id',
        fields: {
            "id": {nullable: true},
            "Date": {editable: false},
            "name": {editable: false},
            "price": {editable: true}
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

},