Skip to Content
avatar image
Former Member

how to set focus textbox in sapui5

I need to know how to autofocus textbox by loading the page

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Feb 05 at 11:02 AM

    Hello ,

    Use the below code, if you have designed the page in javascript

    jQuery.sap.delayedCall(500, this, function() {

    sap.ui.getCore().byId("name").focus();

    });

    If the you have used XML view, write the below code in init function of the respective control.

    jQuery.sap.delayedCall(500, this, function() {

    this.getView().byId("name").focus();

    });

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 20 at 07:12 AM

    Hi,

    instead of onInit, write the function in "onBeforeRendering",

    try this:

    onBeforeRendering: function() {

    jQuery.sap.delayedCall(500, this, function() { sap.ui.getView().byId("asd").focus(); }); }

    Add comment
    10|10000 characters needed characters exceeded