Skip to content

FullCalendar Scheduler Examples

aetasoul edited this page Jul 6, 2021 · 11 revisions

Activating the scheduler

withScheduler

FullCalendar calendar = FullCalendarBuilder.create().withScheduler("My-License").build();

setSchedulerLicenseKey

FullCalendar calendar = FullCalendarBuilder.create().withScheduler().build();
((FullCalendarScheduler) calendar).setSchedulerLicenseKey("My-License");

Adding a resource to a calendar and link it with entries

LocalDate start = LocalDate.now();

Resource resource = new Resource(null, "My Resource", "red");
((FullCalendarScheduler) calendar).addResource(resource);

// When we want to link an entry with a resource, we need to use ResourceEntry (a subclass of Entry)
ResourceEntry entry = new ResourceEntry(null);

entry.setTitle("Dentist");
entry.setStart(start.atStartOfDay());
entry.setEnd(start.plusDays(1).atStartOfDay());
entry.setEditable(true);
entry.setAllDay(true);
entry.setColor("red");
entry.setDescription("Some description...");
entry.assignResource(resource);

calendar.addEntry(entry);

Handling change of an entry's assigned resource by drag and drop

calendar.addEntryDroppedListener(event -> {
    event.applyChangesOnEntry();

    Entry entry = event.getEntry();

    if(entry instanceof ResourceEntry) {
        Set<Resource> resources = ((ResourceEntry) entry).getResources();
        if(!resources.isEmpty()) {
            // do something with the resource info
        }
    }
});

Creating a resource bases background event

LocalDate start = LocalDate.now();

Resource resource = new Resource(null, "My Resource", "red");
((FullCalendarScheduler) calendar).addResource(resource);

// When we want to link an entry with a resource, we need to use ResourceEntry (a subclass of Entry)
ResourceEntry entry = new ResourceEntry();

entry.setStart(start.atStartOfDay());
entry.setEnd(start.plusDays(1).atStartOfDay());
entry.setAllDay(true);
entry.assignResource(resource);
entry.setRenderingMode(Entry.RenderingMode.BACKGROUND); 

calendar.addEntry(entry);

Creating hierarchical resources

// Create a parent resource. When adding the sub resources first before adding the parent to the calendar,
// the sub resources are registered automatically on client side and server side.

Resource parent = new Resource();
parent.addChildren(new Resource(), new Resource(), new Resource());

((FullCalendarScheduler) calendar).addResource(parent); // will add the resource and also it's children to server and client

// add new resources to already registered parents
Resource child = new Resource();
parent.addChild(child);
((FullCalendarScheduler) calendar).addResource(child); // this will update the client side

// or remove them from already registered ones
((FullCalendarScheduler) calendar).removeResource(child); 
parent.removeChild(child); 

Making a resource entry draggable between resources

ResourceEntry entry = new ResourceEntry(null);

// activate for the client to have an entry being draggable between resources
entry.setResourceEditable(true);

// update the entry on the client side, if it is already added to the calendar
calendar.updateEntry(entry);

Switching to a timeline view

calendar.changeView(SchedulerView.TIMELINE_DAY);

Activate vertical resource view

((FullCalendarScheduler) calendar).setGroupEntriesBy(GroupEntriesBy.RESOURCE_DATE);
Clone this wiki locally