Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
155
Remove CustomDay
posted

How to remove CustomDay using Javascript?

  • 24497
    Verified Answer
    posted

    Hi Hasithi,

    WebMonthCalendar does not support persistance of custom days modified on client.
    There is array of those days, so, that array can be modified and any item can be removed. However, you should build logic to find a day which you want to modify. Please look at docs for get_customDays and what members it contains. You also may put debugger and check those members (days).

    Below example will remove day at index 2.

     <script type="text/javascript">
    function removeCustomDay()
    {
     var cal = $find('<%=WebMonthCalendar1.ClientID%>');
     var days = cal.get_customDays();
     //debugger;
     var idToRemove = 2;
     if(idToRemove >= days.length)
      return;
     days[idToRemove] = days[days.length - 1];
     days.length--;
     cal.repaint();
    }
    </script>
    <ig:WebMonthCalendar ID="WebMonthCalendar1" runat="server">
      <CustomDays>
          <ig:CalendarCustomDay Day="5" CssClass="red" />
          <ig:CalendarCustomDay Day="8" CssClass="red" />
          <ig:CalendarCustomDay Day="9" CssClass="red" />
          <ig:CalendarCustomDay Day="15" CssClass="red" />
      </CustomDays>
    </ig:WebMonthCalendar>
    <input type="button" value="clear" onclick="removeCustomDay()" />