Page 1 of 1

Weekends and Time range in Calendar?

Posted: Mon May 05, 2025 11:27 am
by admin
Select calendar region then attriburtes and Initialization JavaScript Function

Code: Select all

function(poptions) {

  // Show weekends
  poptions.weekends = true;

  // Days of the week: 0=Sun, 1=Mon, 2=Tue, 3=Wed, 4=Thu, 5=Fri, 6=Sat
  poptions.firstDay = 1;

  // Show week numbers in the calendar
  poptions.weekNumbers = true;
  // poptions.weekText = "Week:";

  // Slot duration in time grid (how each row is spaced by time)
  poptions.slotDuration = "00:45:00"; // 15-minute slots

  // Define visible time range
  poptions.slotMinTime = "09:00:00";  // Start time
  poptions.slotMaxTime = "18:00:00";  // End time

  // Highlight weekends
  poptions.dayCellDidMount = function(info) {
    const day = info.date.getDay();

    if (day === 0 || day === 6) { // Sunday or Saturday
      info.el.style.backgroundColor = '#f0f0f0';
      info.el.style.color = '#999';
    }
  };  

  return poptions;
}

cal1.jpg
cal2.jpg