如何使用 bindAggregation ui5 在控制器中将列添加到 table

how to add column to table in controller with bindAggregation ui5

 I have created value help

我要的是再增加一栏数量 将它添加到列中不是问题,因为它总共 JSON 但是将它放在行中有点问题 - 因为我从 table 中提取数据 - 产品 - 它们没有数量。 我想通过邀请在这里创建这个 重点是代码是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();
},

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

您的 table 仅包含带有标签的行,因为您的 ColumnListItem 的单元格是通过这种方式创建的。如果你想添加其他东西,你需要调整你的工厂功能。例如:

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

因为它无法登录秒 if (oTable.bindItems) pereps because oTable.setModel(this.oColModel, "columns"); 我把它设为

`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");
                 var oColumn = new sap.ui.table.Column({
                        label: new sap.m.Label({text: "Qty"}),
                        template: new sap.m.StepInput({value: "{Qty}"}),
                        width: "70px",
                        step:"1",
                        largerStep:"1",
                        max:"35",
                        min:"0",
                        stepMode:"Multiple" 
                });

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

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

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

`