Skip to Content

Can i bind list of items to a VBox ?

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Jul 25, 2016 at 04:17 AM

    Hi Rohit,

    You might need to consider using factory definition for VBox 'items' aggregation.

    Will this sample help? Plunker

    In the above sample, I was using 'Explored' mock data: Products.json

    If SupplierName is 'Titanium' then display input control, if it is 'Technocom' then checkbox control, else others would be radio button control.

    Regards,

    Sai.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.