How to add entire date in format we need to column header when field type is year/month/day

Answered
Bharath Reddy asked on June 11, 2024

Hi,

We need the field type in the table to remain as year/month/day. However, when we drag and drop "day" from the fields popup, it only displays the day value. We require it to display the entire date with the specified format. Therefore, the header should include the complete date details of that field, not just the day.

Additionally, I've reviewed the previous solution provided by the team, where cell customization was used. However, the data obtained in the parentMember only has access to the year when it is a month. When I tried the same approach for our table, I found that I only received label data.

You can find the link to the previous solution here: https://jsfiddle.net/flexmonster/zr0jd6Lo/

Could you please look into this? Thank you.

9 answers

Public
Mohammed Affan June 13, 2024

Can someone from the Flexmonster team look into this on priority, please?

TL;DR: When a date field is detected

  • To be able to add a year suffix for Month(Column or row) For example - January 2024
  • To change the format for Date(Column or row) For example - Instead of 1, show 01 Jan 2024
Public
Nadia Khodakivska Nadia Khodakivska Flexmonster June 13, 2024

Hello,

Thank you for reaching out to us.

To display dates with the mentioned format, we recommend the following approach:

Preprocess the data, so you have three fields with the same date. For example,

{
"DateYear": "2021-05-25",
"DateMonth": "2021-05-25",
"DateDay": "2021-05-25",
// other fields
},

Then, use mapping to set the type "date string" and set the necessary interval and format:

mapping: {
"DateYear": {
caption: "Year",
type: "date string",
interval: "y",
format: "yyyy"
},
"DateMonth": {
caption: "Month",
type: "date string",
interval: "M",
format: "MMMM yyyy"
},
"DateDay": {
caption: "Day",
type: "date string",
format: "dd MMM yyyy"
}
}

Please check the following JSFiddle for reference: https://jsfiddle.net/flexmonster/qtcxpkzu/

We hope it helps. Feel free to contact us if other questions arise.

Kind regards,
Nadia

Public
Mohammed Affan June 13, 2024

Can we avoid the Date field being split into three different fields? We need the default grouping behavior as in the image attached.

Attachments:
image (14).png

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster June 14, 2024

Hello,

Thank you for the response.

To group the date fields, we recommend adding the folder property to the mapping. For example:

mapping: {
"DateYear": {
folder: "Date",
caption: "Year",
type: "date string",
interval: "y",
format: "yyyy"
},
"DateMonth": {
folder: "Date",
caption: "Month",
type: "date string",
interval: "M",
format: "MMMM yyyy"
},
"DateDay": {
folder: "Date",
caption: "Day",
type: "date string",
format: "dd MMM yyyy"
}
}

You are welcome to see the following JSFiddle for reference: https://jsfiddle.net/flexmonster/wnackj19/

Please let us know if it works for you. Looking forward to hearing from you.

Kind regards,
Nadia

Public
Bharath Reddy July 11, 2024

Hi the above mapping is working as expected. But there is an issue with filters now. When we try to apply filters on the field, it is not working as expected. I have attached the filter attachment.

This is video link of issue: Link

Could you please look into this? Thank you.

 

Public
Mohammed Affan July 11, 2024

Please check the above case @nadia. It's not just with filters, anything that has to do with the newly mapped date fields like conditional formatting, formula, etc, doesn't work.

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster July 12, 2024

Hello,

Thank you for the reply.

Kindly check if you have removed the previous configurations of the date fields from the mapping. In other words, please check if there are the same fields defined in the mapping with the "year/month/day". If present, please remove those configs. Also, there should be no fields with the same uniqueName. Feel free to check the example: https://jsfiddle.net/flexmonster/wnackj19/. You can see that the filter works as expected.

We hope it helps. You are welcome to contact us if other questions arise.

Kind regards,
Nadia

Public
Mohammed Affan July 15, 2024

This worked. Thanks, Nadia.

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster July 16, 2024

Hello,

Thank you for the response!

We are glad to hear that it works for you.

As always, do not hesitate to write to us if further questions arise.

Kind regards,
Nadia

Please login or Register to Submit Answer