Search code examples
javascriptc#calendardaypilot

Daypilot C# Get Selected Day


I am building a master rota using Daypilot. I only care about Monday -Sunday. I don't care about DATES, just DAYS. E.G a shift created on a Monday between 2-4 will be there every Monday between 2-4.

I am using the TimeRangeSelectedJavaScript to call the modal popup

Is there a way using this javascript to get the selected DAY.

E.G if they try and create a appointment on the weekly calender on a Monday, then "Monday" can be passed through?

    TimeRangeSelectedHandling="JavaScript"
    TimeRangeSelectedJavaScript="timeRangeSelected(start, end,$('#MainContent_DropDownList_Week').val(), $('#MainContent_DropDownListLocationMasterRota').val());"

Solution

  • You can get the day of week from the start/end variables:

    var startDow = start.getDayOfWeek();
    var endDow = end.getDayOfWeek();
    

    Both start and end variables hold a DayPilot.Date object. See also DayPilot.Date.getDayOfWeek().

    Your example modified:

    TimeRangeSelectedHandling="JavaScript"
    TimeRangeSelectedJavaScript="timeRangeSelected(start.getDayOfWeek(), end.getDayOfWeek(), $('#MainContent_DropDownList_Week').val(), $('#MainContent_DropDownListLocationMasterRota').val());"