cancel
Showing results for 
Search instead for 
Did you mean: 

Aggregation binding does not work with named models in xml view

Former Member
0 Kudos

Hello All,

I have been facing issue with binding aggregations in XML views with named models especially when a binding context is set to the view

One strange thing is that local the i18n resource model is working fine when used for strings

Example :

A View is set binding context in controller with model "Amodel" and within the XML view I have a List using different model "BModel" as below

<mvc:View>

<Text  text="{/AModelText}"></Text>

<Table

     items="{BModel>/items}">

     <columns>

       <Column width="12em">

         <Text text="{18nModel>Col1Title}" />

       </Column>

       <Column >

         <Text text="{i18nModel>Col2Title}" />

       </Column>

     </columns>

     <items>

       <ColumnListItem>

         <cells>

           <Text text="{Cell1Text}"/>

           <Text text="{Cell2Text}" />

         </cells>

       </ColumnListItem>

     </items>

</Table>

<mvc:View>

In the above scenario all Col1Title and Col2Title are resolved correctly but since the whole view is set bindingcontext with "Amodel" AModelText is shown but the cells in ColumnListItem does not show any text.

When debugged the reference to binding for Cell1Text and Cell2Text were shown binded to "Amodel"

Any pointers to solve this issue would be of great help because now I have to do all the binding in Controller and use bindAggregations to get the results thus deviating from  the main use of named model.

Regards,

Vijay Sai

Accepted Solutions (0)

Answers (5)

Answers (5)

saivellanki
Active Contributor
0 Kudos

Hi Vijay,

If your model, is like this -


{

     items:[

          {Cell1Text:"dskfdf",Cell2Text:"dfgdfgd"},

          {Cell1Text:"dskfdf",Cell2Text:"dfgdfgd"},

          {Cell1Text:"dskfdf",Cell2Text:"dfgdfgd"}

     ]

}

I used your code and this will work - JS Bin - Collaborative JavaScript Debugging

Regards,

Sai Vellanki.

Private_Member_15166
Active Contributor
0 Kudos


     <items>

       <ColumnListItem>

         <cells>

           <Text text="{Cell1Text}"/>

           <Text text="{Cell2Text}" />

         </cells>

       </ColumnListItem>

     </items>

Instead of this use this.

     <items>

       <ColumnListItem>

         <cells>

           <Text text="{BModel>Cell1Text}"/>

           <Text text="{BModel>Cell2Text}" />

         </cells>

       </ColumnListItem>

     </items>

saivellanki
Active Contributor
0 Kudos

Hi Vijay,

Can you print the model and post the code here? It will be easy to resolve, if we can see the model structure.


Also check in the debugger, what are you getting, when you do .getModel() of BModel>/items.

Regards,

Sai Vellanki.

Former Member
0 Kudos

Hello Sai,

I have given you an example of the scenario and I could not post the model data(client data).

Below could be a sample model structure

{

     items:[

          {Cell1Text:"dskfdf",Cell2Text:"dfgdfgd"},

          {Cell1Text:"dskfdf",Cell2Text:"dfgdfgd"},

          {Cell1Text:"dskfdf",Cell2Text:"dfgdfgd"}

     ]

}

I debugged it and the item for the table tries to find the properties in the AModel as the viwe has bindingcontext to AModel.

former_member182862
Active Contributor
0 Kudos

I think

       <ColumnListItem>
         <cells>
           <Text text="{Cell1Text}"/>
           <Text text="{Cell2Text}" />
         </cells>
       </ColumnListItem>

should be

       <ColumnListItem>
         <cells>
           <Text text="{BModel>Cell1Text}"/>
           <Text text="{BModel>Cell2Text}" />
         </cells>
       </ColumnListItem>

Thanks

-D

Former Member
0 Kudos

Hello Dennis,

I tried using {BModel>Cell1Text} but it does not work as it tries to find the Cell1Text in the BModel where as it should be part of BModel>items

former_member182372
Active Contributor
0 Kudos

do you have data-sap-ui-xx-bindingSyntax="complex" in bootstrap?

Former Member
0 Kudos

Hello Maksim,

Yes, I did set data-sap-ui-xx-bindingSyntax="complex" in bootstrap.

former_member182372
Active Contributor
0 Kudos

how do you set BModel ?

Former Member
0 Kudos

Hello Maksim,

BModel is set to the UIComponent used in the application and the model is available in all the views which are routed using the Component.