Search code examples
listtreeodatasapui5nodes

SAPUI5: Show array of expanded entity Set as sub node in Tree


I have a salesOrder document with expanded to_Item array from api_business hub as test data.. the field to_Item is an object with property results which is an array that contains the salesOrderItems...

The thing is, I want to display the SalesOrderItems for one SalesOrder in a tree hierarchy as subnodes... but I do not know how to display the items as subnode in the tree, it seems the option arrayNames as parameter in the Tree: parameters: { expand: 'to_Item', arrayNames: ['to_Item/results'] } } does not do it: enter image description here

            <Tree
                id="Tree"
                items="{ path: '/A_SalesOrder', parameters: { expand: 'to_Item', arrayNames: ['to_Item/results'] } }"
            >
                <!-- <StandardTreeItem id="SC_StandardTreeItem1" title="{SalesOrder}" /> -->
                <CustomTreeItem id="SC_CustomeTreeItem1">
                    <content>
                        <FlexBox
                            id="SC_FBT1"
                            alignItems="Start"
                            width="100%"
                        >
                            <items>
                                <Text
                                    text="{SalesOrder}"
                                    class="sapUiSmallMarginEnd"
                                />
                                <Text text="{SalesOrderDate}">
                                    <layoutData>
                                        <FlexItemData growFactor="1" />
                                    </layoutData>
                                </Text>
                                <Text
                                    text="{TotalNetAmount}"
                                    class="sapUiSmallMarginEnd"
                                />
                                *****THIS LIST SHOULD BE DISPLAYED AS SUBNODE IN THE TREE*****
                                <List
                                    id="treeList"
                                    items="{
                                        path: 'to_Item'
                                    }"
                                    headerText="Item"
                                >
                                    <ObjectListItem
                                        title="{SalesOrderItemText}"
                                        number="{
                                        parts:[{path:'NetAmount'},{path:'CurrencyCode'}],
                                        type: 'sap.ui.model.type.Currency',
                                        formatOptions: {showMeasure: false}
                                        }"
                                        numberUnit="{TransactionCurrency}"
                                    >
                                        <ObjectAttribute
                                            text="{Material}"
                                        />
                                        <ObjectAttribute
                                            text="{PricingDate}"
                                        />
                                    </ObjectListItem>
                                </List>
                            </items>
                        </FlexBox>
                    </content>
                </CustomTreeItem>
            </Tree>

Solution

  • ok I finally found out how it works with those parameter options:

                        <Tree
                        id="Tree"
                        mode="MultiSelect"
                        items="{path: '/A_SalesOrder',
                                    parameters: {
                                        expand: 'to_Item',
                                        countMode: 'Inline',
                                        navigation: {
                                            'A_SalesOrder': 'to_Item'
                                        }
                                    }
                             
                             }"
                    >
    

    The other problem that I have now is, that it does not automatically fetch more data on scrolling like in a TreeTable...