Skip to Content
avatar image
Former Member

new sap.m.Dialog change button to enabled dynamicly

Hello

I am using new sap.m.Dialog with two buttons

one button should be disabled at first, and after calling a service to get data in the dialog

I have to change it to enabled.

in the Controller.js the code is like this:

In the Controler of the dialog

If the oData_error not equal 'X'

I need to change the button to enabled : true.

Any help will be appreciated.

Thank you.

cart-call.png (17.8 kB)
omodel-read.png (18.5 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Oct 27, 2016 at 03:52 PM

    bind enabled attribute to model, then in your controller code manipulate the model to enable or disable the button

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 27, 2016 at 08:36 PM

    You can give id to the button in the view(suppose 'idBtn'). Take control of the button in the function and enable it.

    sap.ui.getCore().byId("idBtn").setEnabled(true);

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 27, 2016 at 06:13 PM

    its good to set enabled/disable using model property, but you can try below code inside your condition:

    var oLeftBtn = $( "button[id*='"+this._orderDialog.getLeftButton()+"']" ).control()[0];
    oLeftBtn.setEnabled(true);

    Regards,

    Akhilesh

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 30, 2016 at 05:05 PM

    I will go with Jun Wu approach and never use setEnabled function because you have more flexibility when you use model.

    Please take a look at http://jsbin.com/ticenu/edit?js,output

    and change the result value in the setTimeout function to true and false to see how it works.

    Thanks

    Dennis

    Add comment
    10|10000 characters needed characters exceeded