How to Get Value from the OData Expand Binding

I have a List with a binding. In this List, I return bank accounts and over the expand, I get the mandates for each account (1:n).

<List id="bankAccountList"
    itemPress="onListItemSelect"
    items="{
        path: 'BankvbSet',
        parameters: {
            expand: 'MandatSet'
        }
    }"
    noDataText="{i18n>msgNoBankAccount}"
    delete="onEndBankAccount"
>

Now I will check if there are any mandates with an appropriate status. So I have written a formatter for this and in that formatter, I get the data from the $expand. But I only get an array with the path of the mandates. Is there a way to get the complete data?

Here is a piece of my current code:

<List id="bankAccountList"
    itemPress="onListItemSelect"
    items="{
        path: 'BankvbSet',
        parameters: {
            expand: 'MandatSet'
        }
    }"
    noDataText="{i18n>msgNoBankAccount}"
    delete="onEndBankAccount"
>
    <items>
        <ObjectListItem id="template" 
            custom:bankId="{Bankdetailid}"
            type="Navigation"
            intro="{i18n>labelBankId}: {Bankdetailid}"
            title="{Iban}"
            number="{
                path: 'ValidEntry',
                formatter: '.formatter.setBankAccountStateText'
            }"
            numberState="{
                path: 'ValidEntry',
                formatter: '.formatter.setBankAccountState'
            }"
        >
            <attributes>
                <ObjectAttribute
                    title="{i18n>labelBankName}"
                    text="{Bankdesc}"
                />
                <ObjectAttribute
                    text="{
                        path: 'MandatSet',
                        formatter: '.formatter.setLabelMandateVorhanden'
                    }"
                />
            </attributes>
        </ObjectListItem>
    </items>
</List>

And in the formatter I get only the path as array

[
    "MandatSet(Application='1',SepaCreditorId='DE98ZZZ0999',SepaMandateId='5001549101000001',Status='4')",
    "MandatSet(Application='1',SepaCreditorId='DE98ZZZ0999',SepaMandateId='5001549101000002',Status='1')",
    "MandatSet(Application='1',SepaCreditorId='DE98ZZZ0999',SepaMandateId='5001549101000003',Status='1')"
]

1 answer

  • answered 2018-01-09 16:47 Andrii Naumovych

    This is a default behavior of storing navigation property data in ODataModel. Despite of the fact that you get only keys, you can easily retrive the objects behind by utilizing of "getProperty" method of ODataModel.

    If you define your formatter through the controller, it gets called with it's context. Meaning "this" inside formatter function will point to controller instance.

    It means that you can get OData model instance (inside formatter) and call "getProperty" passing the key, which will return you the needed object.