search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Datepicker in corner : events vanish

Asked by kree
4 days ago.

Hello,

I can’t find how to solve events vanish when pick a date.
As said in a previous post, I am not a coder at all, so I take a look of source code and copy/paste, then test in localhost.
I choose html5 scheduler and customise as I can, with other demo. Now, it look like this :

I encountered a problem with icon calendar, never show, even if the cursor come up when it goes below “demo”, so I use a .png instead.

My issue now is when I pick a new date, no events loads or load a second and vanish. If i go back to the first date (ie 25/05) no more events. I have to reload the page, then, events are back. I suppose it is about event update, what tuto I have to look at ?

Is it possible to scroll backwards when you pick a date, I mean, if I am on 25 may, pick 15 july, the scheduler start on 15 july and it is not possible to scroll to 14 july with the mouse. Maybe there is a setting I have to understand ?

The page is linked to 2025.2.6448 js version

Also, I have tested infinite scroll, then the picking a date doesn’t go to the good one, ie, if I pick 1 dec, it goes to 15 sept, maybe datepicker and scroll to infinite can’t leave together ? Is there some tuto I can take a look if they can go on the same scheduler.

Thank you for advice.
Kree

Answer posted by Dan Letecky [DayPilot]
4 days ago.

I assume you are working with the JavaScript Scheduler: Date Picker in the Upper-Left Corner tutorial.

1. The SVG calendar icon is new and you need to use the latest version of daypilot.svg (you can find it in the tutorial download and in the latest release).

2. When changing the visible date range, you need to load events for the new date range. You can update the tutorial code like this:

onClick: args => {
  const picker = new DayPilot.DatePicker({
    target: 'date',
    resetTarget: false,
    date: scheduler.startDate,
    onTimeRangeSelect: async args => {
      args.preventDefault(); // keep the icon intact
      picker.close();

      // load events
      const start = args.start;
      const end = start.addDays(scheduler.days);
      const {data} = await DayPilot.Http.get(`/events?start=${start}&end=${end}`);

      scheduler.update({ startDate: args.start, events: data });
    }
  });
  picker.show();
}

3. The scrolling is limited to the dates between startDate and startDate + days.

The code above uses the clicked date as startDate so you can’t access prior dates by scrolling. You can adjust the first date in the event handler as necessary. For example, you can always start with the first day of the selected month and scroll to the clicked day:

onClick: args => {
  const picker = new DayPilot.DatePicker({
    target: 'date',
    resetTarget: false,
    date: scheduler.startDate,
    onTimeRangeSelect: async args => {
      // ...      

      const startDate = args.start.firstDayOfMonth();

      scheduler.update({ startDate, scrollTo: args.start, ... });
    }
  });
  picker.show();
}

4. If you use infinite scrolling, it’s necessary to change the date using the scrollTo() method instead of update():

scheduler.scrollTo(args.start);
Answer posted by kree
3 days ago.

Hello Dan,

Thank you for these instructions. I look forward to working on them. I'll come back to you to keep you informed of my progress.

See you soon

Kree

New Reply
This reply is
Attachments:
or drop files here
Your name (optional):