Caio Mayer
Top achievements
Rank 1
Caio Mayer
asked on 21 Jan 2008, 10:23 AM
Hi!
We are trying to create a resource, to be used as a checkbox, but it always come with a dropdown. Any problems with our code?
Thanks,
Caio.
We are trying to create a resource, to be used as a checkbox, but it always come with a dropdown. Any problems with our code?
| private void InitializeResources() |
| { |
| ResourceType resType = new ResourceType("Usuários"); |
| resType.AllowMultipleValues = true; |
| resType.ForeignKeyField = "UserID"; |
| RadScheduler1.ResourceTypes.Add(resType); |
| RadScheduler1.Resources.Add(new Resource("Usuários", 1, "Teste 1")); |
| RadScheduler1.Resources.Add(new Resource("Usuários", 2, "Teste 2")); |
| RadScheduler1.Resources.Add(new Resource("Usuários", 3, "Teste 3")); |
| } |
Thanks,
Caio.
5 Answers, 1 is accepted
0
Hello Caio,
When using resources, the dropdown list control is used to display them in the advanced edit form. This is by design and it cannot be changed with the current version of RadScheduler.
However, there is a workaround. You can use Templates and add resources dynamically. Please, consider the Database Scheduler Provider example and try the following code with it:
Should you have any questions, please fee free to contact us.
Cheers,
Peter
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
When using resources, the dropdown list control is used to display them in the advanced edit form. This is by design and it cannot be changed with the current version of RadScheduler.
However, there is a workaround. You can use Templates and add resources dynamically. 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); |
| } |
| } |
| } |
Should you have any questions, please fee free to contact us.
Cheers,
Peter
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Caio Mayer
Top achievements
Rank 1
answered on 21 Jan 2008, 03:46 PM
Hi Peter, thanks for the reply.
What i need is something like this MultipleResourceValues Example
I can´t use templates because i need to use the default advancedInsert.
Thanks.
Caio.
What i need is something like this MultipleResourceValues Example
I can´t use templates because i need to use the default advancedInsert.
Thanks.
Caio.
0
Hello Caio,
Unfortunately, to display resources via any other control than the default dropdown list is only possible through templates.
Best wishes,
Peter
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Unfortunately, to display resources via any other control than the default dropdown list is only possible through templates.
Best wishes,
Peter
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Caio Mayer
Top achievements
Rank 1
answered on 22 Jan 2008, 09:57 AM
Hi Peter,
But on this exemple how this checkbox is made? It is without Template correct?
I´m not getting how this works.
Thanks.
Caio.
But on this exemple how this checkbox is made? It is without Template correct?
I´m not getting how this works.
Thanks.
Caio.
0
Hi Caio,
Yes, that's correct. However, multiple resource are only possible through custom providers as shown in the MultipleResourceValues Example. Also, you need to set AllowMultipleResourceValues="true".
All the best,
Peter
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Yes, that's correct. However, multiple resource are only possible through custom providers as shown in the MultipleResourceValues Example. Also, you need to set AllowMultipleResourceValues="true".
All the best,
Peter
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center