Skip to Content
Jun 22, 2021 at 08:34 PM

SAPUI5: Value help in new line of a Table



I'm using a sap.m.Table to display my table data.

To create a new row, I use a button in the headerToolbar, calling my function addComponent in the press event.

Most of the columns are simple sap.m.Text fields, there is just one sap.m.Input field, which should have a valueHelp. Therefore I set showValueHelp: true, valueHelpOnly: false, valueHelpRequest: this.onMaterialValueHelpRequest.

        addComponent: function(oEvent) {
            var oItem = new sap.m.ColumnListItem({
                cells : [ new sap.m.Input({
                    showValueHelp: true,
                    valueHelpOnly: false,
                    valueHelpRequest: this.onMaterialValueHelpRequested,
                    value: "{Material}"
                }), new sap.m.Text({
                    text: "{MaterialDescription}"
                }), new sap.m.Text({
                    text: "{Price}"
                }), new sap.m.Text({
                    text: "{PriceUnit}"
                }), new sap.m.Text({
                    text: "{RequirementQuantity}"
                }), new sap.m.Text({
                    text: "{RequirementQuantityUnit}"
                showValueHelp : true
                })*/ new sap.m.Button({
                    icon : "sap-icon://delete",
                    press : [ this.deleteComponent, this ]
                }) ]

            var oTable = this.getView().byId("idSalesOrderComponentsTable");

I define the columns of the value help in a json file

    "cols": [
            "label": "Material Number",
            "template": "Material",
            "width": "5rem"
            "label": "Description",
            "template": "Description"
            "label": "Category",
            "template": "Category"

, which I load in the following way:

this.oColModel = new JSONModel(sap.ui.require.toUrl("at/develite/ui/sof/valuehelpdialog") + "/columnModelMaterial.json");

In my onMaterialValueHelpRequest function I try to get the columns, but thus.oColModel is undefined:

        onMaterialValueHelpRequested: function (oEvent) {
            var aCols = this.oColModel.getData().cols;

It seems this is the sap.m.Input field, for which I call the value help.

In all examples, I searched, it is possible to get the columns via this.oColModel...

The error message of in the browser conxole is "Uncaught TypeError: Cannot read property 'getData' of undefined".

Does anybody have an idea, how to fix my problem?