简体   繁体   English

添加后,Kendo Grid内联编辑新行消失

[英]Kendo Grid Inline Edit New Row Disappears After Add

I have a grid with Angular and remote data binding. 我有一个带有Angular和远程数据绑定的网格。 Its configuration is like this: 其配置如下:

    $scope.myGridOptions = {
        dataSource: new kendo.data.DataSource({
                type: "json",
                transport: {
                    create: function(operation) {
                        //calls an Angular service to add
                        DataService.add(operation).success(function(data) {
                            operation.success(data);
                        });
                    },
                    parameterMap: function(options, operation) {
                        if (operation !== "read" && options.models) {
                            return { models: kendo.stringify(options.models) };
                        }
                    }
                },
                pageSize: 10,
                schema: {
                    model: {
                        id: "Id",
                        fields: {
                           ...
                        }
        }),
        toolbar: [ { name: "create", text: "Add New Book" } ],
        autobind: false,
        groupable: false,
        editable: {
            mode: "inline"
        },
        columns: [
            {
                field: "Name",
                title: "Name"
            },
            {
                field: "Description",
                title: "Description"
            },
            {
                command: [
                    { name: "edit", title: "Action" }
                ]
            }
        ]
};

When I click on the "Add New Book" button, the first row in the grid turns into a blank row and allows me to enter data. 当我单击“添加新书”按钮时,网格中的第一行变成空白行,并允许我输入数据。 When finish entering, I click on "Update" to save the data and the first row turns into a regular, read-only row and I verify the new row has been added to the remote database. 输入完毕后,单击“更新”以保存数据,第一行变为常规的只读行,并确认新行已添加到远程数据库中。 So far so good. 到现在为止还挺好。 However, when I click on the "Edit" button on the new row followed by clicking on the "Cancel" button my new row disappears until I refresh the page. 但是,当我单击新行上的“编辑”按钮,然后单击“取消”按钮时,我的新行会消失,直到刷新页面为止。

What am I missing? 我想念什么?

In order for kendo dataSource to sync data after save, you need to return the newly created row back to the dataSource from the server. 为了使kendo dataSource在保存后同步数据,您需要将新创建的行从服务器返回到dataSource。 This is valid for update also. 这对于更新也有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM