首页 > 解决方案 > 如何使用bindAggregation ui5将列添加到控制器中的表

问题描述

 I have created value help

我想要的是添加另一列数量 将它添加到列中不是问题,因为它是全部 JSON 但是将它放在行中有点问题 - 因为我从表中提取数据 - 产品 - 它们没有数量。我想通过邀请在这里创建这个关键是代码是oTable.bindAggregation的形式

这是我的价值帮助 这是我的代码:

onValueHelpRequested: function() {
    var aCols = this.oColModel.getData().cols;
    this._oValueHelpDialog = sap.ui.xmlfragment("Ztest.Ztest.view.ValueHelpDialogBasic", this);
    this.getView().addDependent(this._oValueHelpDialog);

    this._oValueHelpDialog.getTableAsync().then(function (oTable) {
        oTable.setModel(window.orders);
        oTable.setModel(this.oColModel, "columns");

        if (oTable.bindRows) {
            oTable.bindAggregation("rows", "/Items");
        }

        if (oTable.bindItems) {
            oTable.bindAggregation("items", "/Items", function () {
                return new ColumnListItem({
                    cells: aCols.map(function (column) {
                        return new Label({ text: "{" + column.template + "}" });
                    })
                });
            });
        }
        this._oValueHelpDialog.update();
    }.bind(this));

    this._oValueHelpDialog.setTokens(this._oMultiInput.getTokens());
    this._oValueHelpDialog.open();
},

我在这里有一个控件可以将步骤输入插入每一行吗?我的意思是这样的事情: 什么介意输入步骤

标签: sapui5

解决方案


您的表格仅包含带有标签的行,因为您ColumnListItem的单元格是以这种方式创建的。如果您想添加其他内容,则需要调整您的工厂功能。例如:

return new ColumnListItem({
    cells: aCols.map(function (column) {
        if (<condition>) {
            return new StepInput(...);
        } else {
            return new Label({ text: "{" + column.template + "}" });
        }
    })
});


推荐阅读