Skip to main content
June 10, 2024
Question

Hii, I am trying to build calendar component using read only grid but its not showing in proper format

  • June 10, 2024
  • 2 replies
  • 0 views

a!localVariables(
local!startDate: date(ri!year,ri!month,1),
local!daysInMonth: daysinmonth(ri!month,ri!year),
local!startDateDay: weekday(local!startDate),
local!endDateDay: weekday(eomonth(local!startDate,0)),
local!days: {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"},
local!dates: a!forEach(
items: enumerate(local!daysInMonth) + 1,
expression: local!startDate + fv!item - 1
),
local!datesWithDays: a!forEach(
local!dates,
{
day: local!days[weekday(fv!item)],
date: fv!item
}
),
{
a!gridField(
label: "Calendar",
labelPosition: "ABOVE",
data: local!datesWithDays,
columns: {
a!gridColumn(
label: "Sunday",
sortField: "sunday",
value: if(fv!row.day="Sunday",fv!row.date,"")
),
a!gridColumn(
label: "Monday",
sortField: "monday",
value: if(fv!row.day="Monday",fv!row.date,"")
),
a!gridColumn(
label: "Tuesday",
sortField: "tuesday",
value:if(fv!row.day="Tuesday",fv!row.date,"")
),
a!gridColumn(
label: "Wednesday",
sortField: "wednesday",
value: if(fv!row.day="Wednesday",fv!row.date,"")
),
a!gridColumn(
label: "Thursday",
sortField: "thursday",
value: if(fv!row.day="Thursday",fv!row.date,"")
),
a!gridColumn(
label: "Friday",
sortField: "friday",
value: if(fv!row.day="Friday",fv!row.date,"")
),
a!gridColumn(
label: "Saturday",
sortField: "saturday",
value: if(fv!row.day="Saturday",fv!row.date,"")
)
}
)
}
)

Can anyone help?

    2 replies

    daniell
    June 10, 2024

    Your a!gridField.data is using local!datesWithDays, which is an array of dates. Based on what it sounds like you are trying to do, you would actually want your data (i.e. rows) in your grid to be an array of weeks

    jayaprakashr0001
    Participating Frequently
    June 11, 2024

    Divide the dates into respective weeks it will be list of arrays then you can achieve the calendar result