Klevr Product Documentation logo

Using Calendar View

The Calendar View gives us the ability to render a list view tab on the portal as a calendar.

Feature Overview

The Calendar View gives us the ability to render a list view tab on the portal as a calendar. It is as easy as turning on a parameter in Umbraco to render the list as a Calendar. The calendar will visually show start dates and end dates of each event. It also allows you to cycle through the months to see specific dates.

When adding a list there will be a property at the bottom of the list called "Render as Calendar" if activated the list will then be displayed as a calendar. You will also need to write some fetchxml to get the events popping up on the calendar. Below I'll show and explain an example of this. <fetch distinct="true">

Note that the klevr_name are set to parameters listed below to ensure they work.

Below is a list of parameters that you can use in the fetchxml, note that the klevr_name needs to be the name of the properties below. For example: <attribute name="klevr_name" klevr_name="title" />

idString. A unique identifier of an event. Useful for getEventById.
groupIdString. Events that share a groupId will be dragged and resized together automatically.
allDayBoolean (true or false). Determines if the event is shown in the “all-day” section of relevant views. In addition, if true the time text is not displayed with the event.
startDate object that obeys the current timeZone. When an event begins.
endDate object that obeys the current timeZone. When an event ends. It could be null if an end wasn’t specified. Note: This value is exclusive. For example, an event with the end of 2018-09-03 will appear to span through 2018-09-02 but end before the start of 2018-09-03. See how events are are parsed from a plain object for further details.
startStrAn ISO8601 string representation of the start date. If the event is all-day, there will not be a time part.
endStrAn ISO8601 string representation of the end date. If the event is all-day, there will not be a time part.
titleString. The text that will appear on an event.
urlString. A URL that will be visited when this event is clicked by the user. For more information on controlling this behavior, see the eventClick callback. Note that if you specify a "Details Page" in Umbraco (e.g. /event?id={id}), the calendar will automatically browse to this page on click, and substitute the id with the id of the event that was clicked on, so you don't have to specify a URL from fetch. For more advanced scenario's, the Vue Control will emit an onclick event that can be listened to in JavaScript too.
description
colorString, pass a color HEX code to change the color of an event.
backgroundColorThe eventBackgroundColor override for this specific event.
For more visit https://fullcalendar.io/docs/event-object

Changing Colour of Events using PowerFX

You can change the colour of the event in the calendar using a PowerFX Attribute in Power Apps. Below is an example of this.

I created a PowerFX formula that looks like this:

If(DateDiff(localdateandtime, Now()), "#780f07", "#07782b")

This formula checks if the localdatetime is now, if true sets the PowerFX field to a RED colour. Otherwise it will set it to a green. Then if you put this attribute in the calendar's fetchxml on the Portal and set the "klevr_name" to "color".

<fetch distinct="true">
  <entity name="klevr_portaltesting">
    <attribute name="klevr_name" klevr_name="title" />
    <attribute name="klevr_localdateandtime" klevr_name="start" />
    <attribute name="klevr_localdateandtime2" klevr_name="end" /> 
    <attribute klevr_key="true" name="klevr_portaltestingid" klevr_name="id" />
    <attribute name="klevr_calendarcolor" klevr_name="color"/>
  </entity>
</fetch>

The outcome will then change the color of the event to the outcome of the formula from the PowerFX.

For more examples of what you can do within the PowerFX formula visit: Work with formula columns

Assumptions

  1. Understanding of FetchXML. (explained in this document)
  2. Understanding of the portal/umbraco.

Design Details

See https://dev.azure.com/klevr/Klevr%20Apps/_workitems/edit/4059/ for the work item.

📎 References

Last updated on