1

我正在尝试在我的应用程序中使用 Angular Kendo UI。一些视图包括网格。

  <div kendo-grid
     k-sortable ="true"
     k-pageable ="true"
     k-filterable ="true"
     k-resizable ="true"
     k-editable = "'incell'"
     k-selectable = "true"
     k-options = "accountSettingsDS"
     k-columns = '[
         { field: "Companies", title: "Companies", editor : "<input kendo-drop-down-list k-data-text-field=\"&#39;name&#39;\" k-data-value-field=\"&#39;name&#39;\" k-data-source=\"CompaniesList\" ng-model=\"dataItem.Companies\"/>"},
         { field: "Currency", title: "Currency", editor : "<input kendo-drop-down-list k-data-text-field=\"&#39;name&#39;\" k-data-value-field=\"&#39;name&#39;\" k-data-source=\"CurrenciesList\" ng-model=\"dataItem.Currency\"/>"},
         { field: "Account", title: "Account", editor : "<input kendo-drop-down-list k-data-text-field=\"&#39;name&#39;\" k-data-value-field=\"&#39;name&#39;\" k-data-source=\"AccountsList\" ng-model=\"dataItem.Account\"/>"},
         { field: "NCAccount", title: "NCAccount", editor : "<input kendo-drop-down-list k-data-text-field=\"&#39;name&#39;\" k-data-value-field=\"&#39;name&#39;\" k-data-source=\"NCAccountsList\" ng-model=\"dataItem.NCAccount\"/>"}
          ]'
     k-toolbar="['save','cancel']"
     id="accountSettingsGrid">
</div

该网格的 DataSource 的定义如下面的代码所示

    $scope.accountSettingsDS = {
        dataSource: {
            serverPaging: true,
            serverFiltering: true,
            serverSorting: true,
            pageSize: 10,
            type: "odata",
            schema: {
                data: function (response) {
                    if (response.value !== undefined)
                        return response.value;
                    else {
                        delete response["odata.metadata"];
                        return response;
                    }
                },
                total: function (response) {
                    return response['odata.count'];
                },
                model: {
                    id: "id",
                    fields: {
                        id: {
                            type: "number",
                            editable: false
                        },
                        Companies: {
                            type: "string",
                            editable: true
                        },
                        Currency: {
                            type: "string",
                            editable: true
                        },
                        Account: {
                            type: "string",
                            editable: true
                        },
                        NCAccount: {
                            type: "string",
                            editable: true
                        }
                    }
                }
            },
            transport: {
                read: {
                    url: serviceUrl + "AccountsSettings",
                    dataType: "json"
                },
                create: {
                    url: serviceUrl + "AccountsSettings",
                    type: "POST",
                    contentType: "application/json"
                },
                update: {
                    url: function(record) {
                        return serviceUrl + "AccountsSettings" + "(" + record.id + ")";
                    },
                    type: "PUT",
                    contentType: "application/json",
                    dataType: "json",
                    headers: { Prefer: "return-content" }
                },
                destroy: {
                    url: function(record) {
                        return serviceUrl + "AccountsSettings" + "(" + record.id + ")";
                    },
                    type: "DELETE",
                    contentType: "application/json",
                    dataType: "json"
                },
                parametermap: function (data, operation) {
                    console.log(data);
                    if (operation === "read") {
                        var parammap = kendo.data.transports.odata.parametermap(data);
                        return parammap;
                    }
                    return json.stringify(data);
                }
            }
        }
    };

当我编辑网格项目并单击“保存更改”按钮时,没有任何反应。
如果我在没有编辑器的情况下定义网格列,那么数据会正确更新(这样我必须使用默认字符串编辑器)。但我需要自定义编辑器。
我该如何解决这个问题?

4

1 回答 1

1

尝试为编辑器输入赋予 name 属性,以便 Grid 知道要更新模型的哪个属性。

input kendo-drop-down-list name='Account' ...
于 2014-05-27T08:26:36.147 回答