Automatic resizing

4 posts, 2 answers
  1. Regula
    Regula avatar
    44 posts
    Member since:
    Sep 2005

    Posted 09 Sep 2011 Link to this post

    I there.

    I've a timetable in a WeekDay view. Depending on the information got from the datasource, sometimes I have more than 10 concurrent appointments for and sometimes I have only 1 or 3 appointments at the same time. In the case where I have 10 appointments I have to increase the radscheduler width but in cases I have only 1 or 3 appointments I don't want to change the width.

    I don't if it is possible, but I want to in someway to resize automatically the radscheduler based in the number of appointments at the same time. 
    For instance, in a weekview, if the maximum number of concurrent appointments is 2 then I would like to set the radsched width to 500px, if I have 5 concurrent appointments I would like set to 800px and if I have 10 concurrent appointments I'de like to set width to 1000px.

    Is that possible? There is another approach for this problem?


    Thanks




  2. Answer
    Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 13 Sep 2011 Link to this post

    Hi Regula,

    The following code in code-behind shows how to set the ColumnWidth of the RadScheduler automatically.
    CS:
    private int maxAppCount = 0;
        protected void RadScheduler1_TimeSlotCreated(object sender, TimeSlotCreatedEventArgs e)
        {
            if (e.TimeSlot.Appointments.Count > maxAppCount)
            {
                maxAppCount = e.TimeSlot.Appointments.Count;
            }
        }
         
        protected void RadScheduler1_DataBound(object sender, EventArgs e)
        {
            int maxCount = 0;
            foreach (Appointment a in RadScheduler1.Appointments.GetAppointmentsInRange(RadScheduler1.VisibleRangeStart, RadScheduler1.VisibleRangeEnd))
            {
                if(appMaxCount(a) > maxCount)
                {
                    maxCount = appMaxCount(a);
                }
            }
            RadScheduler1.ColumnWidth = Unit.Pixel(maxCount*100);
        }
     
        protected int appMaxCount(Appointment apt)
        {
            int appointmentsCount = 0;
            foreach (Appointment existingApt in RadScheduler1.Appointments.GetAppointmentsInRange(apt.Start, apt.End))
            {
                if (existingApt.Visible)
                    appointmentsCount++;
            }
            return (appointmentsCount);
        }


    Hope this helps.

    Kind regards,
    Ivana
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Regula
    Regula avatar
    44 posts
    Member since:
    Sep 2005

    Posted 13 Sep 2011 Link to this post

    Thanks Ivana.

    There is anyway to change one specific collumn, ie, if I dectect that Thursday has 10 overlaping Appointments, can I increase Thursday collumn only, lefting all other collumns with the same value?

    Thanks
  4. Answer
    Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 14 Sep 2011 Link to this post

    Hello Regula,

    The RadScheduler control in its current form does not support changing of specific column's width.

    All the best,
    Ivana
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal
Back to Top