0
votes

I have a odata model that I want to bind to my table in my XML-view. The thing is, my data consists of objects, and these objects have 1 property that is an array. This array is what i want to show in my table.

I can't make it work, maybe because something like "ToWorkingDays/Data" isn't working with the table binding? Maybe you can help me. The metadata should be right.

My data: First the location and then the "ToWorkingDays" Data:

[{
    "LocationID": 0,
    "Title": "blabla",
    "Subtitle": "subtitle",
    "RandomNumber": "123"
}]

[{ "LocationID": 0,
"WorkingDaysID": 0,
"Data": [{
    "Weekday": "Mon",
    "WorkingTimeStart": "08:00",
    "WorkingTimeEnd": "18:00",
    "PauseTimeStart": "12:00",
    "PauseTimeEnd": "13:00"
}, {
    "Weekday": "Tue",
    "WorkingTimeStart": "08:00",
    "WorkingTimeEnd": "18:00",
    "PauseTimeStart": "12:00",
    "PauseTimeEnd": "13:00"
}] }]

My XML-view:

<Table items="{ToWorkingDays/Data}">
        <columns>
            <Column>
                <Text text="Weekday"/>
            </Column>
            <Column>
                <Text text="Work Time"/>
            </Column>
            <Column>
                <Text text="Pause Time"/>
            </Column>
            <Column hAlign="End"/>
        </columns>
        <items>
            <ColumnListItem>
                <cells>
                    <ObjectIdentifier title="{Weekday}"/>
                    <Text text="{parts: [{path: 'WorkingTimeStart'}, {path: 'WorkingTimeEnd'}], formatter: '.getSpanValue'}"/>
                    <Text visible="{=${PauseTimeStart} !== undefined}"
                        text="{parts: [{path: 'jsonModel>PauseTimeStart'}, {path: 'PauseTimeEnd'}], formatter: '.getSpanValue'}"/>
                    <Button icon="sap-icon://edit" press="onEditPress"/>
                </cells>
            </ColumnListItem>
        </items>
    </Table>

My binding:

this.getView().bindElement({
            parameters: {
                expand: "ToWorkingDays"
            },
            path: "/" + sPath
        });

My error:

List Binding is not bound against a list for /ToWorkinDays/Data

1
Is your model the default unnamed model? What is "ToWorkingDays"?Cmdd
yes it is! and ToWorkingDays is the navigation property to my working dayssleepysimon
Did you try "/ToWorkingDays/Data"? Is your view bound to a single element?Cmdd
yes i tried. <Table items="{/ToWorkingDays/Data}">sleepysimon
If your view is already bound to /ToWorkingDays (meaning sPath in your bindElement is ToWorkingDays), you can just use /Days in your items binding of the TableNitin

1 Answers

0
votes

Normally it should be like this: items="{modelname>/Customers}" and <Text text="{modelname>Name"}/>.

{"Customers":[{
    "ID":1, 
    "Name": "TestCustomer"
}..]}