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

RadScheduler - business object data and resource interface

1 Answer 152 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
drgorin
Top achievements
Rank 1
drgorin asked on 01 Jan 2008, 05:11 PM
Please provide me with a reference for the following implementation of RadScheduler.
 
I use business objects to interact with my data.  I use FoxPro database tables as my data source.  The data tables are connected via the oledbfp data provider and custom data classes to my business objects.  I understand the examples shown for the generic data binding scenarios in the documentation,  however I find there is a  lack of a complete solution involving multiple groups (resources) in the generic binding examples. I am confused as to how to establish the relationship between the appointment list and the resource list in the generic binding mode. I would like to have multiple columns on my RadScheduler indicating the "ROOMS"    that the appointments are in. I am certain that other developers, working exclusively with business objects (ie: mere mortals mm.net framework) could benefit from your comments.
 
Thank you
 
Neil

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 04 Jan 2008, 01:32 PM

Hello Neil,

Thank you for your interest in RadScheduler and for your question. Actually, we have had similary inquiry not too long ago in a support ticket, but you are right that it is good to have a sample code of the solution in the forums.

Please, consider the Database Scheduler Provider example and try the following code with it:

 <AdvancedEditTemplate> 
                <asp:TextBox ID="TitleTextBox" Rows="5" Columns="20" runat="server" Text='<%# Bind("Subject") %>' 
                    Width="95%" TextMode="MultiLine"></asp:TextBox> 
                <div style="position: relative">  
                    <span>Teachers:</span><br /> 
                    <asp:CheckBoxList ID="TeachersCheckBoxList" runat="server">  
                    </asp:CheckBoxList> 
                </div> 
                <br /> 
                <br /> 
                <div> 
                    <span>Students:</span><br /> 
                    <asp:CheckBoxList ID="StudentsCheckBoxList" runat="server">  
                    </asp:CheckBoxList> 
                </div> 
                <asp:LinkButton ID="UpdateButton" runat="server" Text="Update" CommandName="Update" /> 
            </AdvancedEditTemplate> 

protected void RadScheduler1_FormCreated(object sender, SchedulerFormCreatedEventArgs e)     
        {     
               
            CheckBoxList teachers = (CheckBoxList)e.Container.FindControl("TeachersCheckBoxList");     
                    
               foreach (Resource r in RadScheduler1.Resources.GetResourcesByType("Teacher"))     
                {     
                   ListItem listitem1 = new ListItem(r.Text, r.Key.ToString());     
                   listitem1.Selected = ResourceIsInUse(r, e.Appointment);     
                   teachers.Items.Add(listitem1);     
                       
                }     
                CheckBoxList students = (CheckBoxList)e.Container.FindControl("StudentsCheckBoxList");     
    
                foreach (Resource r in RadScheduler1.Resources.GetResourcesByType("Student"))     
                {     
                    ListItem listitem1 = new ListItem(r.Text, r.Key.ToString());     
                    listitem1.Selected = ResourceIsInUse(r, e.Appointment);     
                    students.Items.Add(listitem1);     
                       
                }     
      
                
        }     
        private bool ResourceIsInUse(Resource res, Appointment a)     
        {     
            foreach (Resource appRes in a.Resources)     
            {     
                if (res == appRes)     
                {     
                    return true;     
                }     
            }     
    
            return false;     
        }     
        protected void RadScheduler1_AppointmentCommand(object sender, AppointmentCommandEventArgs e)     
        {     
            CheckBoxList teachers = (CheckBoxList)e.Container.FindControl("TeachersCheckBoxList");     
            CheckBoxList students = (CheckBoxList)e.Container.FindControl("StudentsCheckBoxList");     
            e.Container.Appointment.Resources.Clear();     
                 
                 
                foreach (ListItem item1 in teachers.Items)     
                {     
                    if (item1.Selected)     
                    {     
                        Resource teacher = RadScheduler1.Resources.GetResource("Teacher"int.Parse(item1.Value));     
                        e.Container.Appointment.Resources.Add(teacher);     
                    }       
                }     
                
               foreach (ListItem item1 in students.Items)     
                {     
                    if (item1.Selected)     
                    {     
                        Resource student = RadScheduler1.Resources.GetResource("Student"int.Parse(item1.Value));     
                        e.Container.Appointment.Resources.Add(student);     
                         
                    }                            
                }               
        }    
 


We will appraciate your feedback on this solution and we would like to know if you find it helpful.


All the best,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Scheduler
Asked by
drgorin
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or