-
Notifications
You must be signed in to change notification settings - Fork 27
FullCalendar Scheduler Examples
aetasoul edited this page Jul 6, 2021
·
11 revisions
withScheduler
FullCalendar calendar = FullCalendarBuilder.create().withScheduler("My-License").build();
setSchedulerLicenseKey
FullCalendar calendar = FullCalendarBuilder.create().withScheduler().build();
((FullCalendarScheduler) calendar).setSchedulerLicenseKey("My-License");
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);
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
}
}
});
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);
// 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);
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);
calendar.changeView(SchedulerView.TIMELINE_DAY);
((FullCalendarScheduler) calendar).setGroupEntriesBy(GroupEntriesBy.RESOURCE_DATE);