selecting related apointments

6 posts, 0 answers
  1. Srinivas
    Srinivas avatar
    5 posts
    Member since:
    Dec 2011

    Posted 12 Dec 2011 Link to this post

    hi all

    my radshedular form consist of dropdownlistBox where iam filling all resources
    on selected chanege event of dropdownlistBox i want to display related appointments in radshedular depending upon selected dropdwonlist item and if i do any updation or delete  that should be effect on related seleted dropdwonlist resource item



    please sned me code as soon as possible very urgent
  2. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 15 Dec 2011 Link to this post

    Hi Srinivas,

    Thank you for writing.

    As far as I understand, you want to navigate through the resources of RadScheduler by using a drop-down list. The following code snippet demonstrates how to achieve this:
    public Form1()
    {
        InitializeComponent();
        this.radScheduler1.ActiveView.ResourcesPerView = 1;
        this.radDropDownList1.DataSource = this.radScheduler1.Resources;
        this.radDropDownList1.DisplayMember = "Name";
        this.radDropDownList1.SelectedIndexChanged += new Telerik.WinControls.UI.Data.PositionChangedEventHandler(radDropDownList1_SelectedIndexChanged);
    }
     
    void radDropDownList1_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
    {
        if (this.radDropDownList1.SelectedIndex != -1)
        {
            SchedulerDayViewGroupedByResourceElement dayView = this.radScheduler1.SchedulerElement.ViewElement as SchedulerDayViewGroupedByResourceElement;
            SchedulerMonthViewGroupedByResourceElement monthView = this.radScheduler1.SchedulerElement.ViewElement as SchedulerMonthViewGroupedByResourceElement;
            TimelineGroupingByResourcesElement timelineView = this.radScheduler1.SchedulerElement.ViewElement as TimelineGroupingByResourcesElement;
            if(dayView!=null)
            {
                dayView.NavigateToResource(this.radDropDownList1.SelectedIndex);
            }
            if (monthView != null)
            {
                monthView.NavigateToResource(this.radDropDownList1.SelectedIndex);
            }
            if (timelineView != null)
            {
                timelineView.NavigateToResource(this.radDropDownList1.SelectedIndex);
            }
        }
    }

    I hope this will help you. Do not hesitate to write back if you have any further questions.

    Greetings,
    Ivan Todorov
    the Telerik team

    Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Srinivas
    Srinivas avatar
    5 posts
    Member since:
    Dec 2011

    Posted 15 Dec 2011 Link to this post

    No this is not my required code please  iam Re-writing step by step see attachment also

    1)my winform consist of radschedular ,radnavigator and A DROPDOWNLIST
    2)i am filling all resources in dropdownlist on form load event
    3now i want when i select resource from dropdwonlist radshedular has to display related all appointment  of selected dropdown list  resorce item
    4)now i want to delete/update/insert operations on displayed appointment
    send me code for update/delete/insert   ur privous code for this operations is not wrking



    please u r resoponding time taking too much long

    this code is necessary for me send as passible as
  5. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 15 Dec 2011 Link to this post

    Hello Srinivas,

    Thank you for clarifying your requirements.

    You can use the Visibility property of the appointment to display only appointments that belong to the selected resource. The delete and update operations should work normally without any additional code. To insert appointments correctly, you need to handle the Appointment.CollectionChanging event to listen for new appointments and set their ResourceId. The following code snippet demonstrates this:
    public partial class Form1 : Form
     {
         Color[] colors = new Color[]{Color.LightBlue, Color.LightGreen, Color.LightYellow,
    Color.Red, Color.Orange, Color.Pink, Color.Purple, Color.Peru, Color.PowderBlue};
     
         string[] names = new string[]{"Alan Smith", "Anne Dodsworth",
    "Boyan Mastoni", "Richard Duncan", "Maria Shnaider"};
     
         public Form1()
         {
             InitializeComponent();
     
             for (int i = 0; i < names.Length; i++)
             {
                 Resource resource = new Resource();
                 resource.Id = new EventId(i);
                 resource.Name = names[i];
                 resource.Color = colors[i];
     
                 this.radScheduler1.Resources.Add(resource);
             }
     
             this.radDropDownList1.DataSource = this.radScheduler1.Resources;
              
             this.radDropDownList1.DisplayMember = "Name";
             this.radDropDownList1.ValueMember = "Id";
             this.radDropDownList1.SelectedIndexChanged += new Telerik.WinControls.UI.Data.PositionChangedEventHandler(radDropDownList1_SelectedIndexChanged);
             this.radScheduler1.Appointments.CollectionChanging += new Telerik.WinControls.Data.NotifyCollectionChangingEventHandler(Appointments_CollectionChanging);
         }
     
         void Appointments_CollectionChanging(object sender, Telerik.WinControls.Data.NotifyCollectionChangingEventArgs e)
         {
             if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Add && e.NewItems != null)
             {
                 foreach (Appointment app in e.NewItems)
                 {
                     app.ResourceId = this.radDropDownList1.SelectedValue as EventId;
                 }
             }
     
             UpdateAppointmentVisibility();
         }
           
         void radDropDownList1_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
         {
             UpdateAppointmentVisibility();
         }
     
         private void UpdateAppointmentVisibility()
         {
             foreach (Appointment app in this.radScheduler1.Appointments)
             {
                 if (app.ResourceId == this.radDropDownList1.SelectedValue)
                 {
                     app.Visible = true;
                 }
                 else
                 {
                     app.Visible = false;
                 }
             }
         }
     }

    As to our response times, trial support tickets and forums are answered within 72 hours and support tickets of the licensed users are answered in 24 or 48 hours, depending on the license. This does not necessarily mean that you will have to wait 72 hours to get a response but in this might happen when we have tickets or tasks with higher priority.

    I hope this will help you. Do not hesitate to write back if you need further assistance.

    Kind regards,
    Ivan Todorov
    the Telerik team

    Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

  6. Srinivas
    Srinivas avatar
    5 posts
    Member since:
    Dec 2011

    Posted 20 Dec 2011 Link to this post

    hello


    1)your code is working fine when i creatging a new apointment what about the appointments already exist ! which has no resourcid for already exists appointments


    2) here all resources are displaying in EditAppointment
     3)please on editAppointment window i want to display raddropdown selected item in REsources combo box of ... ok
  7. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 21 Dec 2011 Link to this post

    Hello Srinivas,

    In my opinion, the appointments that do not have an associated resource should be displayed no matter which resource is selected. To achieve this, you just need to check if the appointment's ResourceId property is null:
    private void UpdateAppointmentVisibility()
    {
        foreach (Appointment app in this.radScheduler1.Appointments)
        {
            if (app.ResourceId == this.radDropDownList1.SelectedValue || app.ResourceId == null)
            {
                app.Visible = true;
            }
            else
            {
                app.Visible = false;
            }
        }
    }

    If this differs from your requirements, please let me know and I will assist you in achieving them.

    In case you have any further questions, do not hesitate to ask.

    Best wishes,
    Ivan Todorov
    the Telerik team

    Q3’11
    of RadControls for WinForms is available for download (see what's new). Get it today.
Back to Top
UI for WinForms is Visual Studio 2017 Ready