Skip to Content
0
Jul 25, 2016 at 01:30 AM

Can i bind list of items to a VBox ?

2391 Views

Hello,

I have a requirement where i need to display RadioButton/Checkbox/Input field depending upon the value coming from backend.

Also there will be a list of these values, so based on each value i have to show the corresponding control.

Lets say i am getting 20 records from backend. That means i need to display 20 set of RadioButton/CheckBox/Input

I am thinking to bind the incoming table to the VBox which will replicate itself to 20 times. That is happening.

Just a mock example that i am pasting here:-

<Page title="{i18n>title}">

<content >

<VBox items="{path : 'constantModel>/Queslist'}" class="sapUiSmallMargin">

<Label text="{constantModel>Question}" design="Bold"/>

<Input value="{constantModel>Value}" visible="{constantModel>isInput}"/>

<CheckBox selected="" design="Bold" visible="{constantModel>isCheckBox}"/>

</VBox>

</content>

</Page>

Inside each VBox i am using a number of control & bind them using the visible property.

My Problem is, if i run the code above, it will only replicate CheckBox control 20 times and make them visible depending upon the property.

Lets say, if i use below code

<Page title="{i18n>title}">

<content >

<VBox items="{path : 'constantModel>/Queslist'}" class="sapUiSmallMargin">

<Input value="{constantModel>Value}" visible="{constantModel>isInput}"/>

<CheckBox selected="" design="Bold" visible="{constantModel>isCheckBox}"/>

<Label text="{constantModel>Question}" design="Bold"/>

</VBox>

</content>

</Page>

Now it will replicate the Label 20 times with different Question.

All in all if i am using the aggregate property of a VBox, its only replicating the last control which i have used. But i need to replicate all the controls inside a VBox.

I am using XML views for my application. Its a huge application with 20 views. The above requirement is 1 part of my application.

Please let me know if it can be done using XML views ??

If not, can i use JS views in mix with XML views. Is it possible ??

Thanks,

Rohit