0

I have fragment as mentioned below. I am mapping from a model --> myTable. The columns are visible accept Start Time. I tried different approach for that column. Can any one find the mistake in the code. Below is the JSON Structure :

<core:FragmentDefinition xmlns="sap.m"
    xmlns:core="sap.ui.core">
    <Page id="jobTableDisplayPage" showHeader="false" enableScrolling="true">
        <content>
            <Table id="jobTable" items="{myTable>/d/results/}">
                <columns>
                    <Column width="15em">
                        <Text text="Job Name" />
                    </Column>
                    <Column width="5em">
                        <Text text="User Name" />
                    </Column>
                    <Column width="5em">
                        <Text text="Job Status" />
                    </Column>
                    <Column width="5em">
                        <Text text="Start Date" />
                    </Column>
                    <Column width="5em">
                        <Text text="Start Time" />
                    </Column>
                    <Column width="5em">
                        <Text text="End Time" />
                    </Column>
                    <Column width="5em">
                        <Text text="Spool Number" />
                    </Column>
                </columns>
                <items>
                    <ColumnListItem>
                        <cells>
                            <Text text="{myTable>Jobname}" />
                            <Text text="{myTable>Usern}" />
                            <Text text="{myTable>Status}" />
                            <Text text="{myTable>Startdate}" />
                            <Text
                                text="{  path: '{myTable>Starttime}',
                                         type: 'sap.ui.model.type.Time',
                                         formatOptions: {
                                               relative: true,
                                               relativeScale: 'auto'
                                       }
                                     }" />
                            <Text text="{myTable>Endtime}" />
                            <Text text="{myTable>Spool}" />
                        </cells>
                    </ColumnListItem>
                </items>
            </Table>
        </content>
    </Page>
</core:FragmentDefinition>

The columns are visible accept Start Time. I tried different approach for that column. Can any one find the mistake in the code. Below is the JSON Structure :

{  
   "d":{  
      "results":[  
         {  
            "__metadata":{  
               "id":"blablabla",
               "uri":"blablabla",
               "type":"blablabla"
            },
            "Jobname":"JOB1",
            "Usern":"BC-BATCH",
            "Status":"F",
            "Startdate":"10/27/2017",
            "Starttime":"PT03H00M49S",
            "Endtime":"PT03H31M12S",
            "Spool":"0000033977"
         },
         {  
            "__metadata":{  
               "id":"blablabla",
               "uri":"blablabla",
               "type":"blablabla"
            },
            "Jobname":"JOB2",
            "Usern":"BC-BATCH",
            "Status":"F",
            "Startdate":"10/27/2017",
            "Starttime":"PT03H00M49S",
            "Endtime":"PT03H31M12S",
            "Spool":"0000033977"
         }

      ]
   }
}
Chethan
  • 21
  • 1
  • 8
  • Possible duplicate of [How to Add Date / Time from an Odata Service Correctly into the UI?](https://stackoverflow.com/questions/47593990/how-to-add-date-time-from-an-odata-service-correctly-into-the-ui) – Boghyon Hoffmann Dec 13 '17 at 14:49
  • Did the below answer help? https://stackoverflow.com/a/48251335/ – Boghyon Hoffmann Apr 09 '18 at 15:37

2 Answers2

0

I believe path doesn't need the curly brackets.

Try:

<Text text="{ path: 'myTable>Starttime', type: 'sap.ui.model.type.Time', formatOptions: { relative: true, relativeScale: 'auto' } }" />

luuksen
  • 1,357
  • 2
  • 12
  • 38
0

As mentioned in this answer, you need to use the odata binding type instead of the regular one.

So, in case of the odata type Edm.Time (Starttime and Startdate in your case):

type: 'sap.ui.model.type.Time', --> type: 'sap.ui.model.odata.type.Time',

And yes, the additional curly brackets around the path are invalid. So it should be:

<Text text="{
  path: 'myTable>Starttime',
  type: 'sap.ui.model.odata.type.Time',
  formatOptions: {
    relative: true
  }
}"/>
Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170