Our pure JavaScript Scheduler component


Post by anthonyli »

Hi Support,

I have a question. I want to change the datetime format to "YYYY/MM/DD" on the item "Date rage" from the header context menu, but I can't seem to find any info about that in the docs. How do I do that?

Any help/advice on this is really appreciated. Thanks in advance.

Attachments
2020-09-17_092520.PNG
2020-09-17_092520.PNG (13.84 KiB) Viewed 1014 times

Post by pmiklashevich »

Hello,

It's a simple DateField. And we do not specify format for these fields in the HeaderContextMenu explicitly. Common format for date fields is equal to 'L'.
If you check DateHelper docs, you'll see a table with formats available, where L is:

	L	Y: numeric (n), M : 2d, D : 2d

And it says "(uses browser locale)" which means Intl.DateTimeFormat is used. The country code which the constructor expects is defined in localization file. Please see Core/lib/Core/localization/En.js

        DateHelper : {
            locale       : 'en-US',

Just change the "locale" to the desired country and all dates formats will be fixed in whole application.
See localization guide: https://www.bryntum.com/docs/scheduler/#guides/customization/localization.md

Providing specific format to the date field in the header menu is available in upcoming 4.0 release. You can download 4.0 beta from the Customer zone to check out how it works.
Note, HeaderContextMenu is deprecated. Use TimeAxisHeaderMenu instead. Here is the config which might be used to change date format:

const scheduler = new Scheduler({
    features : {
        timeAxisHeaderMenu : {
            items : {
                dateRange : {
                    text : 'test',
                    menu : {
                        items : {
                            startDateField : {
                                label  : 'foo',
                                format : 'Y'
                            }
                        }
                    }
                }
            }
        }
    },
Снимок экрана 2020-09-17 в 13.04.29.png
Снимок экрана 2020-09-17 в 13.04.29.png (96.68 KiB) Viewed 1002 times

Best,
Pavel

Pavlo Miklashevych
Sr. Frontend Developer


Post Reply