cancel
Showing results for 
Search instead for 
Did you mean: 

Binding Issue - sap.m.Dialog to buttons aggregation

mariusobert
Developer Advocate
Developer Advocate
0 Kudos

Hi All,

I’m writing to you with a problem that’s annoying me since I found it and I cannot come up with a solution. So I was wondering, if someone can actually see the where the problem is hidden.

I'm somehow not able to bind the model to a factory function. Here you can find a very simple example of my problem.


This one works, but isn't what I'm actually looking for, since the aggregation should depend on the model:


var oDialog = new sap.m.Dialog({

title: '{i18n>sap.im.ui.datasource.browse.title}',

content: [

new sap.m.Text({

text: 'content'

})

    ],

    buttons: [

new sap.m.Button({

text: 'test1'

}),

new sap.m.Button({

text: 'test2'

})

    ]

});

oDialog.open();


This one never calls the factory (there's no aggregation at all):


var oDialog = new sap.m.Dialog({

    title: '{i18n>sap.im.ui.datasource.browse.title}',

    content: [

new sap.m.Text({

text: 'content'

})

    ],

    buttons: {

path: '/myPath',

factory: function (){

return [

new sap.m.Button({

text: 'test1'

}),

new sap.m.Button({

text: 'test2'

})

]

}

    }

});

oDialog.open();


And this one doesn't work either:


var oDialog = new sap.m.Dialog({

title: '{i18n>sap.im.ui.datasource.browse.title}',

content: [

new sap.m.Text({

text: 'content'

})

    ]

});

oDialog.bindAggregation('buttons', '/myPath', function(){console.log('res')});

oDialog.open();



Does anyone of you have an idea what's going on here?

Accepted Solutions (1)

Accepted Solutions (1)

former_member182862
Active Contributor
0 Kudos

HI Marius 🙂

From what I understand, this is the way to use factory in this context.

Example

Maybe you can tell us a little more about what you want to achieve, we can help.

-D

mariusobert
Developer Advocate
Developer Advocate
0 Kudos

Hi Dennis,

thanks for the help! I wasn't aware, that I need to bind the property to an array. As far as I can see, I cannot create up to 3 buttons, by binding a single string.

What I want to do is, bind a 'state variable' to the dialog, which defines the current status of the dialog. So if the dialog is in the 'start state' there should be only one button (Cancel). But if the dialog is in another 'edit' state, it should display three buttons (Save, Cancel, Close Dialog).

There are more than two states, and each of them defines a different number, label and press event of the buttons. That's why I wanted to bind the buttons to the state. But I guess I have to come up with another solution now, since it's not possible.

Thanks.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Hope this link might help you in sorting it out your problem,

http://jsbin.com/simarofewudi/9/edit?html,output

regards,

Nagarjun