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

Editing resources depending on appointment

3 Answers 62 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Kris
Top achievements
Rank 1
Kris asked on 28 Oct 2011, 08:02 PM
Hello,

I have added a resource to my scheduler which shows as a dropdown. I need the dropdown to display different values depending on which appointment is selected. What is the best way to go about doing this? Is there an event that I can use to populate the resource just before the edit form displays?

3 Answers, 1 is accepted

Sort by
0
Kris
Top achievements
Rank 1
answered on 28 Oct 2011, 10:18 PM

After doing more research, I attempted to insert a resource using the AppointmentDataBound event. However, the resource did not show when the form rendered. The code snippit is below. Why doesn't this work? Is there any easier way to create resource that need to have different dropdown values per appointment?

protected void radSched_AppointmentDataBound(object sender, SchedulerEventArgs e)
        {
            e.Appointment.Resources.Add(new Resource("Calendar", 1, "Community"));
            e.Appointment.Resources.Add(new Resource("Calendar", 2, "Social"));
        }

Obviously, in my application the calendar name and ID will be dynamic...but I can't even get this to work.
0
Kris
Top achievements
Rank 1
answered on 31 Oct 2011, 07:05 PM
Bump.
0
Ivana
Telerik team
answered on 02 Nov 2011, 01:07 PM
Hi Kris,

To achieve the scenario in question, you could define a finite number of resources for the RadScheduler, and in the OnFormCreated server-side event, you could hide the ones that you do not want to show for a particular appointment; As in the code block below:
void RadScheduler1_FormCreated(object sender, SchedulerFormCreatedEventArgs e)
{
    if ((e.Container.Mode == SchedulerFormMode.AdvancedEdit) || (e.Container.Mode == SchedulerFormMode.AdvancedInsert))
    {
        if (e.Appointment.ID.ToString() == "1")
        {
            RadComboBox resourceRoomCombo = e.Container.FindControl("ResRoom") as RadComboBox;
            resourceRoomCombo.Visible = false;
            WebControl resWebcontrol1 = (WebControl)e.Container.FindControl("LblResRoom");
            resWebcontrol1.Parent.Visible = false;
            resWebcontrol1.Controls.Clear();
        }
    }
}
<telerik:RadScheduler runat="server" ID="RadScheduler1"
    OnFormCreated="RadScheduler1_FormCreated">
    <AdvancedForm Modal="true"/>
    <ResourceTypes>
        <telerik:ResourceType DataSourceID="RoomsDataSource" ForeignKeyField="RoomID"
            KeyField="ID" Name="Room" TextField="RoomName" />
        <telerik:ResourceType DataSourceID="UsersDataSource" ForeignKeyField="UserID"
            KeyField="ID" Name="User" TextField="UserName" />
    </ResourceTypes>
</telerik:RadScheduler>
<asp:SqlDataSource ID="UsersDataSource" runat="server"
    ConnectionString="<%$ ConnectionStrings:TelerikConnectionString %>"
    SelectCommand="SELECT * FROM [Users]"></asp:SqlDataSource>
<asp:SqlDataSource ID="RoomsDataSource" runat="server"
    ConnectionString="<%$ ConnectionStrings:TelerikConnectionString %>"
    SelectCommand="SELECT * FROM [Rooms]"></asp:SqlDataSource>
The example is using the Telerik.mdf database, defined with the following connection string: TelerikConnectionString.

Also, another approach could be to define an advanced edit template for the RadScheduler, and define asp.net controls/elements in there. This way you will not have to deal with resources. In the following code library you could find a demo project, which demonstrates how to implement related RadComboBoxes inside of the advanced form of the RadScheduler: Related Load on Demand RadComboBoxes in the advanced form of the RadScheduler. You could modify the demo project, in order to best fit your needs.

I hope this is helpful.

Greetings,
Ivana
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Scheduler
Asked by
Kris
Top achievements
Rank 1
Answers by
Kris
Top achievements
Rank 1
Ivana
Telerik team
Share this question
or