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

[Solved] Force choosing a resource

4 Answers 154 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Dean
Top achievements
Rank 1
Dean asked on 12 Mar 2008, 02:03 PM
I am new to Telerik and am working on a project using RadScheduler. I am trying to find a way to force the user to choose a resource when creating or editing an appointment (set a default resource to be displayed in the dropdown and eliminate "-" as an option in the dropdown list, but still allow user to change resource). Any suggestions on how to accomplish this?

Thanks,
Dean

4 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 12 Mar 2008, 04:17 PM
Hello Dean,

Here is an example how to do this:

<ResourceTypes> 
            <telerik:ResourceType DataSourceID="SqlDataSource2" ForeignKeyField="RoomID"   
                KeyField="ID" Name="Rooms" TextField="RoomName" /> 
        </ResourceTypes> 


protected void RadScheduler1_FormCreated(object sender, Telerik.Web.UI.SchedulerFormCreatedEventArgs e)  
    {  
        if (e.Container.Mode == Telerik.Web.UI.SchedulerFormMode.AdvancedEdit ||  
            e.Container.Mode == Telerik.Web.UI.SchedulerFormMode.AdvancedInsert)  
        {              
            Control c1 = (Control)e.Container.FindControl("_advancedControlsPanel");  
            Control ResourceControlContainer = (Control)c1.FindControl("ResourceControls");  
            DropDownList resourceDropDown = (DropDownList)ResourceControlContainer.FindControl("Rooms");  
            resourceDropDown.Items.RemoveAt(0);  
        }  
    } 

Let us know if you have further questions.


Best wishes,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Dean
Top achievements
Rank 1
answered on 12 Mar 2008, 06:18 PM
Yes!! Works great! Thank you!
0
HHalim
Top achievements
Rank 2
answered on 29 May 2008, 05:07 PM
For the benefit of anyone else, I got an error from posted code above, so a small correction below.

Replace this line of code:
Control c1 = (Control)e.Container.FindControl("_advancedControlsPanel"); 
With this instead:
Control c1 = (Control)e.Container.FindControl("AdvancedControlsPanel"); 

It really works now.

0
Peter
Telerik team
answered on 30 May 2008, 04:20 AM
Hello Hart,

Thanks for mentioning this. What happened is that in an older version of RadScheduler, the controls in the advanced form were mispelled with one addition underscore "_" in front of their names. So, with later versions you are right that you need to reference the controls from code-behind using your suggestion.


Greetings,
Peter
the Telerik team

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