Sort values by month

Answered
Adam Plumridge asked on November 11, 2021

How can I sort month values in the calendar order?
At the moment they are being sorted in alphabetical order.
You can have a look at our sample at the following page:
https://dev602.mestec.net/
Username: flexmonster
Password: RHp75MJGpnZDxmK9
Thank you.

Attachments:
Month Order.png

1 answer

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster November 11, 2021

Hello,

Thank you for reaching out to us.
 
We have analyzed the data set from your example. It seems that you use simple strings to represent months (for example, "2021-Nov"). In this case, Flexmosnter will operate with the "STARTDT_MONTH" field similar to the simple strings, which results in alphabetical sorting order.
 
You can use one of the following approaches to achieve correct sorting.
 
The sortingMethod approach.
The sortingMethod API call sets custom sorting for hierarchy members. For more details about defining custom sort please refer to the Custom sorting tutorial. You will need to compare different strings (for example, "2021-Sep" and "2021-Oct") to let Flexmonster know the correct order.
 
Using date, year/month/day, or year/quarter/month/day data type.
Flexmonster supports different data types to help represent date and time. Data types are defined in the MappingObject. Flexmonster provides unique functionality (filtering by dates, correct sorting) for these types.
You will need to change the data format in your data set to match one of the supported formats:

  1. ISO 8601. For example:
    • "2021-04-25" – Date.
    • "2021-04-25T21:30:05" – Date and time.
    • "2021-04-25T21:30:05+03:00" – Date and time with a time zone.
  2. Unix timestamp. For example, "2021-04-25" will be 1619298000 in the Unix timestamp format.
    Note that it is important to assign the date type to the Unix timestamp field explicitly. Otherwise, the component will treat this field as a numeric one.

 
Here is a simple example of using the year/month/day data type: https://jsfiddle.net/flexmonster/L2xoyw8f/.
 
Please let us know if it helps.
Looking forward to hearing from you.
 
Kind regards,
Illia

Please login or Register to Submit Answer