This is a migrated thread and some comments may be shown as answers.

MultiViewRows>1 stops OnDayRender working on page load

2 Answers 13 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 22 Oct 2013, 12:19 AM
I have a radcalendar that works fine until I add MultiViewRows="3". Then the OnDayRender event does not fire on page load. OnDayRender fires if  go forward or back, just not the first time it loads. If I change it to MultiViewRows="1" it works fine. How do I get it working  the first time it loads with MultiViewRows="3"? I am using Telerik version 2013.3.1015.35.

This is my control:

<telerik:RadCalendar  ID="cldDates" runat="server" AutoPostBack="true" OnDayRender="rCalander_Render"  ShowRowHeaders="false" ShowOtherMonthsDays="false" MultiViewRows="3" Skin="Simple">
</telerik:RadCalendar>


This is my OnDayRender function:



        List<DateTime> enddates = new List<DateTime>();
        List<DateTime> StartDates = new List<DateTime>();
        public void rCalander_Render(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)
        {
 
            var bookingdates2 = from d in DbContext.ihh_Bookings where d.lngHouseID == HouseID && d.dtmEndDate >= new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1) && (d.lngBookingStatusID != 7 && d.lngBookingStatusID != 1 && d.lngBookingStatusID != 10) select d;
 
 
            foreach (ihh_Booking w in bookingdates2)
            {
 
 
                //var bookingdates = from d in DbContext.ihh_HouseBookings_Webs where d.HouseID == HouseID select d;
                //foreach (ihh_HouseBookings_Web w in bookingdates)
                //{
 
                if (e.Day.Date == w.dtmStartDate)
                {
 
                    StartDates.Add(w.dtmStartDate.Value);
                }
                if (e.Day.Date >= w.dtmStartDate && e.Day.Date <= w.dtmEndDate)
                {
                    e.Day.IsSelectable = false;
                    e.Cell.BackColor = System.Drawing.Color.Red;
                    e.Cell.ToolTip = "Booked";
                    cldDates.SpecialDays.Add(e.Day);
 
                }
 
                if (e.Day.Date == w.dtmEndDate)
                {
                    e.Day.IsSelectable = false;
                    e.Cell.BackColor = System.Drawing.Color.FromArgb(Convert.ToInt32("1EA7D8", 16));
                    e.Cell.ToolTip = "Check Out";
                    cldDates.SpecialDays.Add(e.Day);
                    enddates.Add(w.dtmEndDate.Value);
                }
 
 
            }
            foreach (DateTime t in StartDates)
            {
 
                if (enddates.Contains(t) && e.Day.Date == t)
                {
                    e.Day.IsSelectable = false;
                    e.Cell.BackColor = System.Drawing.Color.Purple;
                    e.Cell.ToolTip = "Check out/In";
                    cldDates.SpecialDays.Add(e.Day);
                }
 
            }
            DateTime dtStartDate = (cldDates.CalendarView as Telerik.Web.UI.Calendar.View.MonthView).MonthStartDate;
            DateTime dtEndDate = (cldDates.CalendarView as Telerik.Web.UI.Calendar.View.MonthView).MonthEndDate;
 
            if ((e.Day.Date < dtStartDate || e.Day.Date > dtEndDate))
            {
                // e.Cell.Visible = false;
                e.Cell.BackColor = System.Drawing.Color.White;
 
            }

        }

2 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 24 Oct 2013, 07:20 AM
Hi Michael,

I have prepared a sample web site using the reported RadControls version to test the described behavior. On my side the event is triggered on initial page load as expected. Can you please run the attached application and let us know if it works correctly from your end, too?

Regards,
Eyup
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Michael
Top achievements
Rank 1
answered on 24 Oct 2013, 09:06 AM
Yes it works from my end and solves my problem. Thanks for your help.
Tags
Calendar
Asked by
Michael
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Michael
Top achievements
Rank 1
Share this question
or