Our pure JavaScript Scheduler component


Post by Landpoint »

Hi,

I am looking for a way to only show a row (resource) on the scheduler if they have anything scheduled in the timeaxis specified.

Is there an existing property for this on the main scheduler object, or resource store?

Post by pmiklashevich »

You can try to filter them out, but please keep in mind they will also be missing in the event editor, since event editor uses the same resource store. See this demo: https://www.bryntum.com/examples/scheduler/filtering/

Pavlo Miklashevych
Sr. Frontend Developer


Post by pmiklashevich »

It's been decided to use unfiltered values in Event Editor by default. Ticket here: https://app.assembla.com/spaces/bryntum/tickets/7604

Pavlo Miklashevych
Sr. Frontend Developer


Post by Landpoint »

Perhaps I should clarify:
In the demo you send me to, the filter only removes the events themselves, not the individual rows for the resources.
I suppose what I am asking for is a bit on the Resource object which tells the scheduler to render that whole Row or not.
This way, they can still be listed in the resources array, but it is only deciding if it needs to be physically rendered.

My use case is this:
We have 200 employees in one organization.
We do not want to list 200 rows of mostly empty things, so we only (by default) want to show employees who have things scheduled in the specified timeaxis.
However, we want to be able to with the aid of an additional list on or page turn on/off the rows for any other employees we wish to show.
We envision controlling who will render on the list by appending a checkbox to our list of resources we drag onto the schedule with.
See Image:

Thanks!
Attachments
employees.png
employees.png (121.05 KiB) Viewed 2893 times

Post by pmiklashevich »

The first column in the filtering demo filters resource store by resource.name equal to the input value. If you type in "Arcady" for example you'll see just one resource on the screen. The idea I suggested is to apply custom filter to the resource store and check if the resource has events in the current timespan. Something like this:
scheduler.resourceStore.reapplyFilterOnAdd = true;
scheduler.resourceStore.reapplyFilterOnUpdate = true;

scheduler.filterOutEmptyResources = () => scheduler.resourceStore.allCount && scheduler.resourceStore.filterBy(resource => {
    return resource.events.some(event => {
        return DateHelper.intersectSpans(event.startDate, event.endDate, scheduler.startDate, scheduler.endDate);
    });
});

scheduler.on('timeaxischange', scheduler.filterOutEmptyResources);

scheduler.eventStore.on('change', scheduler.filterOutEmptyResources);

scheduler.resourceStore.on('load', scheduler.filterOutEmptyResources);

// And if you need to show all
// scheduler.resourceStore.clearFilters();

Pavlo Miklashevych
Sr. Frontend Developer


Post by Landpoint »

Thanks for this,
I will give it a try now!

Post by Landpoint »

Yes, it took me a few attempts to get it right, but I was able to get it working as you described here!
Thanks

Post by pmiklashevich »

Hi again @Landpoint, this topic may be interesting for you: viewtopic.php?f=44&t=10527

Pavlo Miklashevych
Sr. Frontend Developer


Post by Landpoint »

pmiklashevich wrote: Wed Feb 13, 2019 12:49 pm Hi again @Landpoint, this topic may be interesting for you: viewtopic.php?f=44&t=10527
Yes, I looked at it...similar.

I am having a slight issue with the solution you provided for me.
On most accounts, it really works perfectly, with the exception that the now filtered resource list is preventing me from re-assigning a task to someone who is not in the filtered list.

Does that make sense to you?

I need to maintain the full list of resources in the resources array, but only "render" those in the schedule which have events specified in the TimeRange, but I should be able to make new events for people not filtered and move/reassign events to people not in presently shown.

Thanks!

Post by pmiklashevich »

Yes, you're right. That's the problem I told you about at the beginning. The resource store is the same for the scheduler and for the event editor. So if you filter out values in the scheduler you can't assign to them either.
It's been decided to use unfiltered values in Event Editor by default. Ticket here: https://app.assembla.com/spaces/bryntum/tickets/7604

Pavlo Miklashevych
Sr. Frontend Developer


Post Reply