Reputation: 73
Read multiple question here regarding this problem, but none of them helped.
I have the following table:
<Table id="table"
width="auto"
items="{
path: '/Master',
sorter: {
path: 'id',
descending: false
},
parameters: {
expand: 'ToB'
}
}"
>
How can I display properties from ToB
in my table?
Because ToB
has a one to many relationship with Master
, this isn't working (I guess that's the reason):
<cells>
<Text text="{ToB/name1}" />
</cells>
whereas this works:
<cells>
<VBox items="{ToB}">
<Text text="{name1}"/>
</VBox>
</cells>
ToB
has a property "selected" which can be 0
or 1
. Only one of the entries to an ID in the Master
table can be 1
, so I thought that is a way to get my 1
to 1
relationship.
But I can't work out, how to do this, already tried it with expression binding:
<Text text="{= ${ToB/selected} === 1 ? ${ToB/name1} : 'No Entry'}"/>
but it always displays "No Entry" in my table.
Edit: for testing purposes it tried:
<Text text="{= ${ToB/selected} === 1 ? ${ToB/name1} : ${ToB/name1}}"/>
but it just leaves the column of my table empty, so I'm guessing the binding isn't correct.
Edit 2: to clarify my question, I got it working using VBox, but I want to have 1 entry per row i.e. there are the names Peter, Paul, and Mary for the specific ID, only Peter has the "selected" value 1
, so I want just Peter in this table row.
Upvotes: 3
Views: 2737
Reputation: 18054
The reason why text="{ToB/name1}"
doesn't work is because resolving the path ToB
returns a collection due to the "many"-cardinality which doesn't work for property binding.
This means also, on the other hand, that it works for aggregation binding as you could observe already with <VBox items="{ToB}"/>
.
I want to have 1 entry per row i.e. there are the names Peter, Paul, and Mary for the specific ID, only Peter has the "selected" value 1, so I want just Peter in this table row.
If you'd like to display only a certain entity from ToB
in <VBox>
, you could define a filter respectively in the view directly. In your case, by "selected" === 1
.
<Table items="{
path: '/Master',
parameters: {
expand: 'ToB'
}
}">
<items>
<ColumnListItem>
<VBox items="{
path: 'ToB',
filters: [
{
path: 'selected',
operator: 'EQ',
value1: 1
}
]
}">
<Text text="{name1}"/>
</VBox>
<!-- ... -->
</ColumnListItem>
</items>
<!-- ... -->
</Table>
Upvotes: 1