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

Initial events load seems to happen before onBeforeCellRender()

Asked by Iain Cochrane
4 years ago.

Hi there - we're using the onBeforeCellRender() function to display the % allocation for an event, just like your example: https://doc.daypilot.org/scheduler/resource-utilization/.

What we see is when the scheduler is first loaded, the % allocation is not shown, indicating that when the event is firing, there isn't an event in that cell to calculate the utilisation. We're loading the events data onScroll(), again, like the example.

When you scroll away and come back, or edit/move an event, the utilisation appears just fine. Same as when you create a new event. Just wondering what it is we're doing wrong. Here's (hopefully), the relevant parts of the code:

dp.scrollDelayEvents = 0;
dp.infiniteScrollingEnabled = true;
dp.dynamicLoading = true;
dp.beforeCellRenderCaching = false;
// load new events as we scroll
dp.onScroll = function (args) {
    args.async = true;

    const start = args.viewport.start;
    const end = args.viewport.end;

    $.ajax({
        type: "GET",
        url: "/api/events",
        data: {
            start: start.toString(),
            end: end.toString()
        },
        success: function (data) {
            args.events = data;
            args.loaded();
        }
    });
};
Comment posted by Iain Cochrane
4 years ago.

I should add that we load resources and then call dp.init(). After the init, scheduler automatically makes a call to the events API passing in the start and end dates like so:

http://localhost:8081/api/events?start=2020-12-01T00%3A00%3A00&end=2020-12-20T09%3A00%3A00

We never make an explicit initial events load call.

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

This issue should be fixed now in the latest sandbox build (2020.4.4805). Could you please give it a try and let me know if the problem persists?

https://javascript.daypilot.org/sandbox/

Comment posted by Iain Cochrane
4 years ago.

Thanks Dan - that does fix it! And thanks for the fast response too.

Is it OK to use this build in production? We've not bought the license yet (waiting on the PO). When are you expecting this to be formally released?

Comment posted by Dan Letecky [DayPilot]
4 years ago.

Iain - Great, thanks for the update.

The sandbox build is only good for testing and the next release is scheduled for December 15:
https://release.daypilot.org/changes/js/

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.