Hi guys,
I've a table to display the following items:
[
{
"ID": "109309714021884",
"UnitPrice": "4.08",
"QuantityPicking": "0.0",
"QuantityShipping": "0.0",
"QuantityDelivered": "2000.0",
"QuantityCancelled": "0.0",
"StatusKey": "Picking"
},
{
"ID": "109309714021906",
"UnitPrice": "6.53",
"QuantityPicking": "0.0",
"QuantityShipping": "0.0",
"QuantityDelivered": "1000.0",
"QuantityCancelled": "0.0",
"StatusKey": "QuantityDelivered"
}
]
My table is like so:
<Table id="orderTable" items="{SalesOrderItemsNavigation}">
<columns>
<Column>
<Text text="{i18n>detailLineItemTableIDColumn}"/>
</Column>
<Column hAlign="End">
<Text text="{i18n>detailLineItemTableUnitPriceColumn}"/>
</Column>
<Column hAlign="End">
<Text text="{detailView>/tabSpecificQuantityColumn}"/>
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<ObjectIdentifier title="{Material}" text="{ID}"/>
<ObjectNumber number="{parts: ['UnitPrice', 'currency'], type: 'sap.ui.model.type.Currency', formatOptions: { showMeasure: false }}" unit=""
emphasized="false" state="None"/>
<ObjectNumber number="{path: './', formatter: '.formatter.specificQuantity'}"
unit="{MeasureUnit}" emphasized="true" state="None"/>
</cells>
</ColumnListItem>
</items>
</Table>
What I want to do is to display based on the StatusKey the corresponding quantity. For example: For the first record the StatusKey is "Picking" so on the first row of my table in the third column (quantity) I want only the "QuantityPicking" value to be displayed.
I know I can achieve this creating one entry of ObjectNumber for each property and then using the visible attribute with an expression, but that is messy.
Is there any good way of achieving this?
I thought about a formatter but the thing is, I don't know how to pass the whole item for the formatter and I don't want to pass the four quantities plus the Status Key as parts.
The formatter method should be something like this:
specificQuantity: function(oObject) {
var key = "Quantity"+oObject.StatusKey;
return oObject[key];
}
Any Ideas,
Thanks
Add comment