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

[Solved] Custom Resource Types

1 Answer 208 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Wade Leveille
Top achievements
Rank 1
Wade Leveille asked on 15 Feb 2008, 04:22 PM
Is there a way to have a custom resource type?  It looks like the scheduler only support radiobuttonlists and dropdownlists.  What if I want to add a textbox, or even a usercontrol??

The reason I'm trying to do this is because I am currently using the advancedinserttemplate and advancededittemplate, but I just learned that you can't use the recurrences with these templates....and I need recurrences as well.

Thanks!

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 18 Feb 2008, 11:44 AM
Hello Wade,

You can do this from code-behind. 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);     
                         
                    }                            
                }               
        }    
 

However, please be advised that for Q1 2008 in April we will extend the current template's support to allow the use of resources and recurrences along with custom templates.


Regards,
Peter
the Telerik team

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