Our pure JavaScript Scheduler component


Post by alex.l »

Hi lucadiba,

Check your code. As far as I see you used getTimeParams().startDate as a value for startDate. Maybe the problem in that value. If you will use proper value for schedulerRef.startDate, you will get the result you need.
Try to use new Date() ?

All the best,
Alex


Post by lucadiba »

i changed it with

new Date()

but it doesnt bring me back on the current time, seems like he only reads the date part and not the time


Post by alex.l »

Please attach your application here, we will check what's wrong.

All the best,
Alex


Post by lucadiba »

thanks, i attached the test case

Attachments
custom-event-editor.rar
(2.46 MiB) Downloaded 35 times

Post by alex.l »

Ok, I see the problem.

To keep time in dateField value, please set https://bryntum.com/docs/gantt/api/Core/widget/DateField#config-keepTime

All the best,
Alex


Post by lucadiba »

Unfortunately keepTime does not work, I re-attach the test case with keepTime

Attachments
custom-event-editor.rar
(2.48 MiB) Downloaded 32 times

Post by alex.l »

keepTime works a bit different.
From docs:

A flag which indicates what time should be used for selected date. false by default which means time is reset to midnight.

Possible options are:

  • false to reset time to midnight
  • true to keep original time value
  • '17:00' a string which is parsed automatically
  • new Date(2020, 0, 1, 17) a date object to copy time from
  • 'entered' to keep time value entered by user (in case format includes time info)

When you set it true, it will keep the original time value. You need to pass a date object to copy time from.

This is the code you need:

const dateField = schedulerRef.tbar.widgetMap.datePicker;
dateField.keepTime = new Date();
dateField.value = new Date();
dateField.keepTime = false; // to prevent applying current time when using datafield arrows

Original value for keepTime in the field config should be false as well. Just omit it, it false by default.
Please also check code of your onChange handler in you datefield. I am not sure if you need all that logic with diff in your solution, maybe you simply need

                onChange({ value }) {
                    const schedulerRef = scheduler.current?.instance;
                    schedulerRef.startDate = value;
                }

But I am not sure, it depends on your business logic.

Good luck in your development.

All the best,
Alex


Post Reply