on 08-18-2015 2:46 PM
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
<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>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
how do you set BModel ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.