Skip to Content

UI5 Binding to Dialog

How does one bind to a Dialog that has not yet been opened?.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Mar 22, 2017 at 06:19 PM
     this.oDialog.bindElement(oTableData[index]);  the parameter should be the path to the data, not the data directly.
    Add comment
    10|10000 characters needed characters exceeded

  • Mar 22, 2017 at 09:26 AM

    1. Create a fragment file for dialog

    2. add fragment to your view

    <l:VerticalLayout>
        <l:content></l:content>
        <l:dependents>
            <core:Fragment fragmentName="demo.dialogFragment" type="XML"></core:Fragment>
        </l:dependents>
    </l:VerticalLayout>

    3. bind dialog

    in onInit function of view, get dialog id which is defined in fragment ( this.oDialog = this.byId("dialogId") ),
    
    //bind dialog in oninit or patterenroutmatch function
    this.oDialog.bindElement(bindingPath);

    4. open dialog

    this.oDialog.open();

    hope this help.

    Add comment
    10|10000 characters needed characters exceeded

    • It's okay Jun, I have found this issue. The link I had only shows some of the source code. I have found another link that shows all of the code, and can see from that how it is working.

  • Mar 22, 2017 at 12:04 PM

    you can define the binding in the fragment if the binding is static, just like your view, do you need to open the view then define the binding??

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 22, 2017 at 01:17 PM
     this.oDialog = this.byId("idDialog");
    
    you already store the dialog in the controller(this), why bother to get it again?
    Add comment
    10|10000 characters needed characters exceeded

    • What I can't find ANYWHERE, is a single example of a binding to a Dialog (XML).

      I can use

      sap.ui.getCore().byId('inputId').setValue("Smith");

      and also getValue as well to retrieve the values entered, but what I can't seem to do is bind a single record (in my case) model to the Dialog. Then reference that model/field from within the Dialog (XML) within <Input/> as an example.