I want to change component’s viewing date with ‘DropDown’ filter.
There are lots of anwers about ‘view changing’ but, nothing about ‘changing date’ T^T
can i get some great answers about that ?
<div>
<select value={year} onChange={onYearChange}>
<option value={2023}>2023</option>
<option value={2024}>2024</option>
<option value={2025}>2025</option>
<option value={2026}>2026</option>
<option value={2027}>2027</option>
{/* add more years if necessary */}
</select>
<select value={month} onChange={onMonthChange}>
<option value={1}>January</option>
<option value={2}>February</option>
<option value={3}>March</option>
<option value={4}>April</option>
<option value={5}>May</option>
<option value={6}>June</option>
<option value={7}>July</option>
<option value={8}>August</option>
<option value={9}>September</option>
<option value={10}>October</option>
<option value={11}>November</option>
<option value={12}>December</option>
</select>
</div>
<FullCalendar
plugins={[dayGridPlugin, interactionPlugin]}
height={'70vh'}
events={events}
datesSet={({ start, end }) => onChangeStartEnd(start, end)}
eventClick={onEventClick}
dateClick={onDateClick}
selectable="true"
/>
I want to associate select tag with Fullcalendar
2
Answers
Handle the change event of the select tags (I don’t know how that’s done in React specifically, but it looks like you do, I could only do it in vanilla JS), and then in the callback, run https://fullcalendar.io/docs/Calendar-gotoDate to tell fullCalendar to change the date.
See the "Calendar API" section of https://fullcalendar.io/docs/react if you need to know how to get access to the fullCalendar object in order to call its functions.
Make sure you include
in your
<FullCalendar
declaration, and then you can use the function along these lines:I’ve made something similar, here is my code. Try to implement and let me know if you need more assisstance