使用模板和放大器;在网格列编辑与角剑道UI剑道、放大器、网格、模板

由网友(公子的心上人)分享简介:我试图用角剑道UI在我的应用程序。一些观点包括电网。I'm trying to use Angular Kendo UI in my app. Some views include grid.
我试图用角剑道UI在我的应用程序。一些观点包括电网。

I'm trying to use Angular Kendo UI in my app. Some views include grid.

  <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在code定义如下图所示。

DataSource for this grid is defined like in code below

    $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);
                }
            }
        }
    };

当我编辑的网格项,然后点击保存更改按钮,没有任何反应。结果如果我正确定义网格列没有编辑,然后数据更新(这样我必须使用默认字符串编辑器)。但我需要自定义编辑器。结果我怎样才能解决这个问题呢?

When I edit grid item and click "Save changes" button nothing happens. If I define grid columns without editors then data updates correctly(in this way I have to use default string editor). But I need custom editors. How can I resolve this problem?

推荐答案

尽量给name属性编辑器输入,因此电网会知道要更新的模型的属性。

Try to give name attribute to the editor input, so the Grid will know which property of the model to update.

input kendo-drop-down-list name='Account' ...