George
George

Reputation: 1

Extend standard UI5 control

I want to add an additional text property to sap.ui.unified.MenuItem. It currently has only one text property.

I am trying the following

        sap.ui.unified.MenuItem.extend("ExtendedMenuItem",{
            metadata:{
                properties:{
                    SetText : {type: "string"}

                },
                aggregations: {
                    _SecondText : {type: "sap.ui.commons.Label", multiple : false, visibility: "public"}
                }
            },
            init: function(){
                var oSecondText = new sap.ui.commons.Label("TL",{
                    text: this.SetText
                });
                this.addAggregation("_SecondText",oSecondText);
            },
            renderer:"sap.ui.unified.MenuItemRenderer"
        });

        var oTestCopy = new ExtendedMenuItem("TC",{
            text: "TEST COPY",
            SetText: "CTRL+TEST"
        });

but the second text property is not being displayed. What can i do to add a second text property to a standard UI5 control ?

Upvotes: 0

Views: 2166

Answers (1)

nistv4n
nistv4n

Reputation: 2535

Here is an example from the official documentation of Custom Controllers. You have to implement the renderer itself to place the new m.Label element on the UI. In the renderer, you can operate with standard HTML elements. For more details, check the linked source.

Upvotes: 1

Related Questions