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

Accessing the resource drop down

5 Answers 141 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 15 Aug 2008, 04:23 PM
In the appointment created event, I want to access the Resource drop down.  Is it possible through that event?  I want to apply css based on what drop down item is selected.  The example on the website uses e.appointment.subject, but is there a way to get to the appointments resource drop down?

5 Answers, 1 is accepted

Sort by
0
Murad Ajani
Top achievements
Rank 1
answered on 15 Aug 2008, 04:38 PM
Hi

I'm also looking for the same. I have used the AdvancedFormTemplate with BooleanAttributeControl.ascx, ResourceControl.ascx. I can able to Implement in the AdvancedEditForm.ascx but when i try to access those Objects like Dropdown or Checkbox in the FormCreated Event it says nothing. I tried e.Container.FindControl and e.Appointment.AppointmentControls nothing works.
 
Please give us some idea.
0
Murad Ajani
Top achievements
Rank 1
answered on 15 Aug 2008, 10:39 PM

I found the checbox control using the following command and the application works fine. But tell me is this correct way.

Dim chkAu As New CheckBox

ResCtrl = e.Container.FindControl(

"AdvancedEditForm1").FindControl("AdvancedEdit").FindControl("AdvancedForm1").FindControl("AdvancedEditOptionsPanel").FindControl("AdvancedControlsPanel").FindControl("ResourceControls")

chkAu = ResCtrl.FindControl(

"ChkAudit").FindControl("AttributeValue")

If chkAu.Checked Then

 AttributeValue is the checkbox ID in the file BooleanAttributeControl.ascx.


 

0
Accepted
Peter
Telerik team
answered on 18 Aug 2008, 11:30 AM
Hello guys,

You can find the resource dropdown control in the FormCreated event. Here is how:

 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))  
        {  
            DropDownList resourceDropDownList = (DropDownList)e.Container.FindControl("Room");  
            resourceDropDownList.BackColor = System.Drawing.Color.Red;  
        }  
    } 

"Room" is the name of the specific resource type:
 <ResourceTypes> 
                <telerik:ResourceType   
                    DataSourceID="AccessDataSource2"   
                    ForeignKeyField="RoomID"   
                    KeyField="ID"   
                    Name="Room"   
                    TextField="RoomName" /> 
            </ResourceTypes> 

You will have to replace "Room" with the name of your resource type.

Murad, using templates is also a possible solution, but it is a little complicated. The approach we recommend is the one shown above, unless there are other requirements to your case which we are not aware of.

Let us know if you have further questions.


Greetings,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Chris
Top achievements
Rank 1
answered on 19 Aug 2008, 02:37 PM
Actually, I have another question.  Is there a way to perform error handling on what is selected in that drop down?  Right now I have this:

Protected Sub trsTrainingScheduler_Insert(ByVal sender As Object, ByVal e As SchedulerCancelEventArgs)
        If e.Appointment.Subject = String.Empty Then
            e.Cancel = True
        End If
    End Sub

Is there a way to say if the drop down value "-" is selected, or if the first item in the drop down is selected?
0
Peter
Telerik team
answered on 20 Aug 2008, 11:14 AM
Hello Chris,

You can simply access the resource type in the AppointmentInsert or AppoitmentUpdate event and check its value. For example:

protected void RadScheduler1_AppointmentInsert(object sender, SchedulerCancelEventArgs e)  
    {  
        if (e.Appointment.Resources.GetResourceByType("Room") == null)  
            e.Cancel = true;  
    } 



Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Scheduler
Asked by
Chris
Top achievements
Rank 1
Answers by
Murad Ajani
Top achievements
Rank 1
Peter
Telerik team
Chris
Top achievements
Rank 1
Share this question
or