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

How to hide resources without events

Asked by Anonymous
7 months ago.

Hi,
How can I hide resources, that don't have any events at all?
Thanks

Answer posted by Dan Letecky [DayPilot]
7 months ago.
Comment posted by Anonymous
7 months ago.

Thanks. I assume I have to call DayPilot.Scheduler.rows.filter() after assigning the resources and the events properties. However, the first time I show the scheduler all rows get removed, even the ones with events. When I change the day (I'm showing just one day) it works. I'm not sure If this is related to my code or maybe you have an idea, what I could be.

Comment posted by Anonymous
7 months ago.

Beside this the event onRowFilter is getting called 4 times, although I have just 2 rows. It should be like this?

Comment posted by Dan Letecky [DayPilot]
7 months ago.

The filter is applied during every full update, including init(). Calling rows.filter() also requests a full update, unless it is called before init().

You should check the order in which the updates are executed. Asynchronous calls can be executed in any order.

If there are no events visible, it means the filter is applied before events are loaded. Loading events using update({events}) will result in an optimized partial update which doesn't re-apply the filter (the onRowFilter handler is not called).

See also:
https://api.daypilot.org/daypilot-scheduler-update/

I would recommend the following:

1. Call rows.filter() before init() to apply the initial filter.
2. When loading events, make sure that you request a full update, like this:

dp.events.list = [ /* ... */ ];
dp.update();

Instead of this which will perform a partial update only:

const events = [ /* ... */ ];
dp.update({events});

To prevent multiple updates when loading resources and events, you can wait for both HTTP requests to complete and perform a single update:

https://code.daypilot.org/49902/javascript-scheduler-wait-for-parallel-http-requests

If you update both resources and events at the same it will request a full update:

dp.update({events, resources});
This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.