vkurko / calendar

Full-sized drag & drop JavaScript event calendar with resource & timeline views

Home Page:https://vkurko.github.io/calendar/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use view object

PHCPartsAlexis opened this issue · comments

Hi All,

I've not got a lot of experience with JS so you'll have to forgive the rather n00b question, but how do I interact with the view object? I can't see any examples of how to do this, and all the things I've tried just result in the calendar not rendering!

I've tried this;
<script type="text/javascript"> let ec = new EventCalendar(document.getElementById('ec'), { view: 'resourceTimeGridWeek', height: '700px', headerToolbar: { start: '', center: 'title', end: '' }, scrollTime: '07:00:00', currentStart='2023-6-12', firstDay: 1,

(and obviously then supplying event data)

I've tried to do similar with views, naming a new view and supplying type, currentStart etc. to no avail.

This is the best calendar solution I've come accross btw, and vastly easier than some of my own home-brew efforts! Thanks to the dev's for the high quality package.

Cheers,

Alexis.

Sorry if I don't quite understand what exactly your question is. You can see a working example in the demo. The source code for the demo page is also available.

I've also prepared this very simple code example for you.

Thanks for the prompt reply! I've got the calendar displaying, but what I am trying (and failing) is to convince the code to start at a given date, rather than displaying the current week.

I basically am building a room booking display system - so want to show "today" and the next 7 days for people to see availability.

So I looked for an option for this, but I could only find it under the view object and it's currentStart method. But I can't make it work.

The currently displayed date is set by the date option.

Can you provide me an example of how I would use that option with a javascript date object please?

Here the currently displayed date is January 7, 2024.

Ah, thank you very much, that helps my understanding. However when using a week view, setting the date to any day within that week still only displays that week, not a week starting from the specified date which is what I'm trying to do :)

Setting the correct value for date in combination with the correct value for firstDay will most likely get you the desired result 😄

Aha, bingo. Nice one :) Thanks for your help!