问题
In the items property of Table I set my path:
items="{path: 'model>/elements/idStabMagTable/elements/'}">
Now I want map two different model (model
with data and enable
that manage the type of row)
<items>
<ColumnListItem type="{enable>row_enable}"> //"Navigation" or none
<cells>
<Text text="{model>society/description}"/>
...
</cells>
</ColumnListItem>
</items>
This is my model model
:
"idTable": {
"elements": [
{
"language": {
"code": "01",
"description": "ITALIANO"
},
"scheda": "rome"
},
{
"language": {
"code": "04",
"description": "TEDESCO"
},
"scheda": "berlino"
}
]
}
and this is my model enable
"idTable": {
"elements": [
{
"language": true,
"scheda": true,
"_row": true
},
{
"language": false,
"scheda": false,
"_row": false
}
]
}
I save the two models into two different file and I manage it into two different JSONModel. Now I want in each row set the values by the first model and the enable information by the 2nd model
But in items path I can map only one path! Can I map two model? (model
and enable
)
回答1:
I have found my solution! It works fine and allow me to maintain differents models.
If in a Table (or List) I have this path for my elements:
items="{path: 'model>/elements/idStabMagTable/elements/'}">
if I want bind a property in the model model in ColumnListItem I write
<Text text="{model>society/description}"/>
If I have a 2nd model enable
with the SAME STRUCTURE of model
model I can map the same property but in the enable
model in this mode:
<Text text="{parts:[{path:'model>society'}], formatter:'ui5bp.Formatter.elementEnable'}"/>
This is my formatter function:
elementEnable: function (oEl) {
var sPath = this.getBindingInfo("text").binding.oContext.sPath;
var sProperty = this.getBindingInfo("text").parts[0].path;
sPath=sPath+"/"+sProperty;
var oEnableModel= ui5bp.products.getModel("enable"); //same path, different model
var oValueEnable=oEnableModel.getProperty(sPath);
return oValueEnable;
}
来源:https://stackoverflow.com/questions/27920300/multiple-items-path-in-sap-m-table