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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Hide days outside current month in month view

Thread ID:

Created:

Updated:

Platform:

Replies:

130415 May 11,2017 03:21 PM UTC Aug 31,2018 12:11 PM UTC Xamarin.Forms 3
loading
Tags: SfCalendar
Ryan Korsak
Asked On May 11, 2017 03:21 PM UTC

(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!

Rathana Kumar Sekar [Syncfusion]
Replied On 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.

Regards,
Rathanakumar S.


George Thomas
Replied On 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).

Vigneshkumar Ramasamy [Syncfusion]
Replied On 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.

Regards,
Vigneshkumar R  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;