We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Hide days outside current month in month view

(I tried editing my original post, and it lost all formatting.  Re-posting...)

I am trying to modify the calendar to only display days in the current month (e.g. if I am looking at May, any cells for April or June are completely blank - no date, appointments, etc.)

I have had some success with listening to the OnMonthCellLoaded event and setting an empty View if the day is outside the current month: 

private void MonthCellLoaded(objectsender,MonthCellargs)
    if (args.Date.Month != _calendar.DisplayDate.Month) { args.View = newGrid(); }

This seems to work pretty well until the user swipes to change months. To enable swiping, the above logic runs on all days in the current month as well as all days in the previous and next months. But, as far as I can tell, there's nothing in the args to indicate the month for which the cell is being loaded, so the entire previous and next months are blank as the user swipes:

So my questions are:
  1. Is there a way to tell, during the OnMonthLoadedEvent, whether a cell is being loaded for its own month or an adjacent month?
  2. Is there some other entirely different way of accomplishing this?
Thanks in advance!

3 Replies

RK Rathana Kumar Sekar Syncfusion Team May 12, 2017 09:30 AM UTC

Hi Ryan,

Thanks for contacting Syncfusion Suppport.

We have checked the reported requirement from our side and we have prepared the sample which we have try to meet your requirement. Please find the sample from the below link.

Note: In your sample you try to achieve your requirement using Calenader DispalyDate API, but in our current implementation DisplayDate API only get update when all cells for the specific month is loaded.

Please let us know if you have any other query.

Rathanakumar S.

GT George Thomas August 31, 2018 07:13 AM UTC

The sample provided below is not woking correctly, when the user swipes left and right some of the dates are getting blank in every month.

If the date selection spans across two month and when the calendar is loaded the month view flickers and the month view is not displaying correctly.
This happens when we call MoveToDate(particular date).

VR Vigneshkumar Ramasamy Syncfusion Team August 31, 2018 12:11 PM UTC

Hi George Thomas, 
Thanks for contacting Syncfusion support.

Based on the provided information, we have checked issue with “when swipe left to right the month dates are getting blank and the date selection spans across two months the month view do not updated correctly while using MoveToDate in SfCalendar” and it is working fine from our side. In previous provided sample the current month variable will hold only the current month details it does not have the previous month view and next month view details so the month view getting blank when swipe. We have modified the sample, please find the sample from the below link,

Sample link: http://www.syncfusion.com/downloads/support/forum/130415/ze/Sample975658986.zip  

Code snippet to show current month in SfCalendar:


                      void Calendar_OnMonthCellLoaded(object sender, MonthCell args)
                          if (!args.IsCurrentMonth)
                              args.View = new Grid();


If the given sample also doesn’t meet your requirement, could you please modify the provided sample along with its reproducing procedure? It will be helpful for us to analyze on your requirement and provide you a possible solution.

Vigneshkumar R  

Live Chat Icon For mobile
Up arrow icon