Display week numbers in Month View

2 posts, 0 answers
  1. Andreas
    Andreas avatar
    144 posts
    Member since:
    May 2008

    Posted 20 Jun 2017 Link to this post

    Hi,

    Is it possible to display the week numbers in the month view?
    This would also be nice, since you could navigate to the week this way...

    Regards
    Andreas

  2. Peter Milchev
    Admin
    Peter Milchev avatar
    613 posts

    Posted 22 Jun 2017 Link to this post

    Hello Andreas,

    Such functionality would require custom implementation. For example, you can customize the timeslots to show the week number using an approach similar to the Scheduler - Customizing the Time Slots online demo.

    Here is a sample implementation of the suggested approach which you could use as a starting point.

    <telerik:RadScheduler ID="RadScheduler1" runat="server" SelectedView="MonthView" OnTimeSlotCreated="RadScheduler1_TimeSlotCreated"></telerik:RadScheduler>
    public static int GetWeekNumber(DateTime dtPassed)
    {
        CultureInfo ciCurr = CultureInfo.CurrentCulture;
        int weekNum = ciCurr.Calendar.GetWeekOfYear(dtPassed, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
        return weekNum;
    }
     
    protected void RadScheduler1_TimeSlotCreated(object sender, TimeSlotCreatedEventArgs e)
    {
        if ((sender as RadScheduler).SelectedView == SchedulerViewType.MonthView)
        {
            int currentWeek = GetWeekNumber(e.TimeSlot.Start.Date);
            Label currentWeekLabel = new Label() { Text = " Week " + currentWeek };
            e.TimeSlot.Control.Controls.Add(currentWeekLabel);
        }       
    }

    Regards,
    Peter Milchev
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top