-
Hi all, So in simple words, for a simple "hello world" example, how can I display an event like this one in the calendar?
to the calendar?
Sorry for this super basic question and thanks a lot in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
@miatemma You have two choices: 1) use the "day" slot, or 2) use the "week" slot. The "week" slot is a bit more complicated, but once you get the hang of things, it should get easier. For now, we'll stick with the "day" slot. As each calendar cell is drawn, it calls the "day" slot. The slotted data contains As a side note, if you were fetching data from a server, you would use the In the example, it uses this code: <template #day="{ timestamp }"> That is how the The next phase is to get all the events for that date. Because there could be more than one, we loop through it with this code: <template v-for="(event, index) in getEvents(timestamp.date)"> The Then for each event returned, the following code is drawn into the calendar cell: <q-badge
:key="index"
style="width: 100%; cursor: pointer; height: 16px; max-height: 16px"
:class="badgeClasses(event, 'day')"
:style="badgeStyles(event, 'day')"
>
<q-icon v-if="event.icon" :name="event.icon" class="q-mr-xs"></q-icon><span class="ellipsis">{{ event.title }}</span>
</q-badge> Hope that helps... |
Beta Was this translation helpful? Give feedback.
@miatemma You have two choices: 1) use the "day" slot, or 2) use the "week" slot. The "week" slot is a bit more complicated, but once you get the hang of things, it should get easier. For now, we'll stick with the "day" slot.
As each calendar cell is drawn, it calls the "day" slot. The slotted data contains
{ timestamp }
.timestamp.date
has the date in the formYYYY-MM-DD
. You use this information to get your data and return it so it can be drawn in-place in the day slot.As a side note, if you were fetching data from a server, you would use the
@change
emit, which containsstart
andend
(which is beginning and end of each calendar month). Then fetch the data from the server between and i…