TKCalendar display only dates of current month for month view

4 posts, 0 answers
  1. avinash
    avinash avatar
    6 posts
    Member since:
    Dec 2018

    Posted 26 Apr 2019 Link to this post

    Hi Team,

    I am using Calendar Control and in month view mode it currently shows 

    previous month's last week dates and next months first week dates as well.

    Is it possible to show only dates for current month .?

    Please let me know how we could achieve it.

     

    Thanks,

    Avinash

     

  2. Yana
    Admin
    Yana avatar
    4993 posts

    Posted 01 May 2019 Link to this post

    Hello Avinash,

    You can hide the dates from the previous and last months through a CalendarDelegate and UpdateVisualsForCell method, however, keep in mind that this will not  affect the calculations that the calendar does to position its cells and it will still display 6 rows.

    Here is a quick snippet:

    public class CustomCalendarDelegate : CalendarDelegate
    {
            public override void UpdateVisualsForCell(TKCalendar calendar, TKCalendarCell cell)
            {
                base.UpdateVisualsForCell(calendar, cell);
       
                var dayCell = cell as TKCalendarDayCell;
                if (dayCell != null)
                {
                    dayCell.Hidden = (dayCell.State & TKCalendarDayState.CurrentMonth) == 0;
                }
            }
    }


    For additional information, please check Calendar Customizations topic.

    Regards,
    Yana
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. avinash
    avinash avatar
    6 posts
    Member since:
    Dec 2018

    Posted 12 Jun 2019 in reply to Yana Link to this post

    Thanks Yana for reply,

    It indeed helped me.

    Is it possible to reduce the number of rows in order to show current months dates only?

     

     

  4. Yana
    Admin
    Yana avatar
    4993 posts

    Posted 12 Jun 2019 Link to this post

    Hi Avinash,

    I am afraid the count of the rows cannot be changed. You'd need to have 6 rows to ensure there will be enough room for all the dates of each month ( for example, if 1st is the last day of the week, 30th will be placed on the 6th row). 

    An alternative approach would be to use the Flow ViewMode for RadCalendar on iOS, please check Calendar ViewModes topic for more details on this:
    https://docs.telerik.com/devtools/xamarin/nativecontrols/ios/calendar/view-modes#flow-layout-with-months-and-month-days

    Regards,
    Yana
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top