In SAPUI5's JSView, it is quite easy to pass the current control reference to a formatter function:
oTable.bindItems("/rows", new sap.m.ColumnListItem({
cells : [ new sap.m.Text().bindProperty("text", {
parts: [
{ path: "someInteger" }
],
formatter: function(iValue) {
var idText = this.getId(); //this references the current control
return iValue;
}
})]
}));
(The 'easy' part of course is because this
is referenced in the control's inner formatter function)
However, with XMLViews I haven't managed yet to get a reference to the current control in the formatter function:
<Table items="{/rows}">
<columns>
<Column>
<Text text="Some Integer" />
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Text text="{ path : 'someInteger', formatter : '.formatCell' }" />
</cells>
</ColumnListItem>
</items>
</Table>
And the formatter:
formatCell : function (sValue) {
var a = this; //this references the controller
return sValue;
}
Anyone knows how to make this work in XMLViews?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…