0
votes

How can i make (Text Field + three buttons) as default child controls for my custom ui5 control.Whenever my custom control loads, it should render (text field + three buttons) inside my custom control by default.

Regards, Karthik S

1
Can you please share the code and place where you face the error ? - Nandan Chaturvedi
I checked this blog. (blogs.sap.com/2016/07/18/how-to-create-a-custom-ui5-control/…). There they added the child controls to their Custom Control as aggregation in the xml view. But my requirement is like whenever my Custom control loads, it should render TextField + buttons as child controls by default. Is there any possibility for my requirement. - Karthik
You can remove from aggregation and keep render the buttons. - I.B.N.
Can you explain me with any samples? Because I want to arrange Text field at the top and three buttons at the bottom(buttons arranged horizontally). - Karthik
Using (--oRm.write("<button>") oRm.writeEscaped("Button 3")--) I can create buttons at runtime in renderer fucntion. But how do i attach event for button which is generating at runtime at reneder function? - Karthik

1 Answers

0
votes

in events: onholdevent": {},

in agrredation:

"button": {
 type: "sap.m.Button",
 multiple: false
},

in onIt:

this.setAggregation("button", new sap.m.Button({
    text: "On Press",
    press: function() {
        that.fireOnholdevent(this);
    }
}));

in render : oControl.getAggregation("button");

main thing is the this refrence , through 'this' you can get in controller which button is clicked .In the view just give the event name and refrence it in controller.