cancel
Showing results for 
Search instead for 
Did you mean: 

Error when using sortByType="Year" in a Timeline

davidsigleinit
Explorer
0 Kudos

Hi all,

I use a Timeline control and set the "groupByType" property to "None" and it works just fine, but it isn't grouping by "Year". When I set the "groupByType" property to "Year" I get the error "The given date instance isn't valid". I believe this is because either the Date I get from the ODate isn't in the correct format for the conversion or because the SAPUI5 version isn't compatible with OData V2. I have tried with a formatter to change it into the appropriate format, but to no avail.

I'm using an OData V2 Service to get the Data for the Timeline and SAPUI5 Version 1.71.51.

Yifan
Advisor
Advisor
0 Kudos

I used Odata V4 and get same error message in CAP + Node.js project.

Accepted Solutions (1)

Accepted Solutions (1)

leonikussmaul
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi David,

Have you defined the field to group by and this field contains a date value? You can see a working example here.

<Timeline
groupByType="Year"
groupBy="dateTime">

As per the error message, the date value is not in a valid format for the Timeline control to group by year, meaning that the timeline control is expecting a different format. If your OData Service is sending 'date' type (Unix epoch time) i.e. "Date(1672531200000)" it should work automatically.

If you want to convert the data type on the client side - what was the issue with the custom formatter? Is it returning a JavaScript date object (new Date) and have you bound the formatter to the view and loaded it from the controller?

If this doesn't work, you could always use a Custom Grouping function. This allows you to specify how the Timeline should group items based on their date property. Once you have defined your grouping function, you can assign it to the Timeline control's "groupBy" property.

davidsigleinit
Explorer

Thank you for the answer.

In the end the fault was on my end. I had to set groupByType="Year" and groupBy="MessageCreDate", so to the field of the items I want to group by.

Answers (0)