How can I use binding for a different entity inside a Table control?

Viewed 80

I have a SAPUI5 Table which has aggregation 'items' bound to the 'Expenses' entity of my OData.
'Expenses' is a part of the main Entity 'Claim', there is an Association in the OData between them. I am using the $expand command in the call to get the main ClaimSet with the expanded entity inside.
<Table items={odata>Expenses} ...

I have a Delete button in each row I want to hide if the main entity 'Claim' has the flag 'submitted: true'. This is now a read only entry so the button should not be shown.

The FlexibleColumnLayout page I'm using is bound to the odata ClaimSet.

var oView = this.getView().byId("ObjectPageLayout");
...
oView.bindElement({
    path: "/" + sObjectPath, //looks like: /ClaimSet('12345')
    model: "odata"
});

I cannot use visible="{odata>Submitted}" for the button, as 'odata>' is now referring to the Expenses entity, not the Claim entity. I am able to access Claim outside of the table, for example a the top of the view in the header section.

How can I access the main Claim entity inside the context of the Expense entity? Is there a way of doing this without creating a separate jsonmodel? I'd like to keep it inside the XML if possible.

2 Answers

Or maybe you can loop on your dataset and add the submitted flag from Claim Set to Expense Set itself checking on some key fields!

Not sure of how the both sets look, so not sure if this will help you or not! but you can always try!!

visible="{odata>/submitted}" should do the work. With odata> you tell the model, and with the / you tell the absolute path of a property of this model and not of the aggregation.

Be careful with the capitalization. If is "submitted" put that and not "Submitted".

Related