Set the starting week to current week

2 posts, 0 answers
  1. Leng Xiong
    Leng Xiong avatar
    1 posts
    Member since:
    Jun 2012

    Posted 17 Nov 2009 Link to this post

    Is there a way using the RadCalendar or setting the Calendar for the RadDatePicker to set the first week that appears in the calendar pop-up to the current week. For example, like today, the date is November 17th. I want the calendar to start from Sunday the 15th and display half of December, instead of displaying the whole entire month of November. I am not concerned with the days of this month that have already passed, but I don't want to just disable those days, I don't even want to show them. Is this possible?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 18 Nov 2009 Link to this post

    Hi Leng Xiong,

    I tried following code in order to achieve the scenario. Give a try with this and see whether it helps.

    aspx:
     
        <telerik:RadDatePicker ID="RadDatePicker1" runat="server" OnPreRender="RadDatePicker1_PreRender"
            <Calendar ShowRowHeaders="False" UseColumnHeadersAsSelectors="False" UseRowHeadersAsSelectors="False"
            </Calendar> 
            <DateInput DateFormat="M/d/yyyy" DisplayDateFormat="M/d/yyyy"
            </DateInput> 
        </telerik:RadDatePicker> 

    cs:
     
        protected void Page_Load(object sender, EventArgs e) 
        { 
            RadDatePicker1.Calendar.DayRender += new Telerik.Web.UI.Calendar.DayRenderEventHandler(Calendar_DayRender); 
        } 
        void Calendar_DayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e) 
        { 
            if (e.Day.Date < DateTime.Now.Date) 
            { 
                e.Cell.Style.Add("display""none"); 
            } 
        } 
        protected void RadDatePicker1_PreRender(object sender, EventArgs e) 
        { 
            RadDatePicker1.Calendar.FirstDayOfWeek = (System.Web.UI.WebControls.FirstDayOfWeek) DateTime.Now.DayOfWeek; 
        } 

    Regards,
    Shinu.
Back to Top