Change Day Color or Hide Day based on date.

3 posts, 0 answers
  1. Allan
    Allan avatar
    121 posts
    Member since:
    Jun 2008

    Posted 22 Aug 2011 Link to this post

    I have a request to change the color of days and make the days read-only based on today's date plus 10 days.

    For example, today is August 22, I would like to change the color of days (or hide them) and make them read-only from September 1st back.

    (August 22 + 10 days = Sept 1st)

    Is this possible?

    Thank you in advance.
  2. Ivan Zhekov
    Admin
    Ivan Zhekov avatar
    539 posts

    Posted 24 Aug 2011 Link to this post

    Hi Allan,

    It's quite possible.

    All you need to do is define your date range (like you mentioned today plus 10 days) and add class names / manipulate styles directly to change the colours / hide the cells.

    However, hiding the cells with CSS is not recommended, as it may lead to unwanted behaviour of the scheduler. Instead, all such actions should be performed in the backend and the days you want to hide should be filtered out from the data source.

    All the best,
    Ivan Zhekov
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Allan
    Allan avatar
    121 posts
    Member since:
    Jun 2008

    Posted 24 Aug 2011 Link to this post

    Here is the solution I found that works for me.


    Protected Sub RadScheduler1_TimeSlotCreated1(sender As Object, e As Telerik.Web.UI.TimeSlotCreatedEventArgs) Handles RadScheduler1.TimeSlotCreated
        If e.TimeSlot.Start.CompareTo(DateTime.Now.AddDays(+10)) = -1 Then
            'e.TimeSlot.CssClass = "Custom"
            e.TimeSlot.Control.Controls.Clear()
        End If
    End Sub

    You can either define a custom CSS to color the background, or like I chose, just hide the day altogether.

    Allan
Back to Top