I'm looking for a way to validate the Rooms drop down on the Advanced form. I want to required that a room has to be selected when creating the appointment and then show an indicator as to which field is required. Can this be done with the scheduler control?
8 Answers, 1 is accepted
0
Hello Nick,
You can add validation to the resource dropdownlist control using custom user controls as shown in the Customizing the Advanced Template example.
An easier solution is to simply handle FormCreated and remove the empty ("-") item from the dropdownlist control. For example, if you have a resource type with Name="Room" you can use the following code:
Best wishes,
Peter
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
You can add validation to the resource dropdownlist control using custom user controls as shown in the Customizing the Advanced Template example.
An easier solution is to simply handle FormCreated and remove the empty ("-") item from the dropdownlist control. For example, if you have a resource type with Name="Room" you can use the following code:
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 resDdl = e.Container.FindControl("ResRoom") as DropDownList; |
resDdl.Items.RemoveAt(0); |
} |
} |
Best wishes,
Peter
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
John Yoo
Top achievements
Rank 1
answered on 23 Jul 2009, 08:52 PM
Peter,
I've tried to perform these steps myself, however I can't get it to work (I'm using the Q2 09 release).
My resource's name is "Calendar", and I tried the call to FindControl with both the "Calendar" name and the "ResCalendar" name.
Here's my code:
protected void scheduleDisplay_FormCreated(object sender, SchedulerFormCreatedEventArgs e)
{
if (e.Container.Mode == SchedulerFormMode.AdvancedEdit ||
e.Container.Mode == SchedulerFormMode.AdvancedInsert)
{
Control panel = e.Container.FindControl("AdvancedControlsPanel") as Control;
Control resourceControlContainer = panel.FindControl("ResourceControls") as Control;
DropDownList calendarResourceDropDown = e.Container.FindControl("ResCalendar") as DropDownList;
if (calendarResourceDropDown == null) // this is from a different post
calendarResourceDropDown = resourceControlContainer.FindControl("ResCalendar") as DropDownList;
calendarResourceDropDown.Items.RemoveAt(0); // here it is still null
}
}
I've tried to perform these steps myself, however I can't get it to work (I'm using the Q2 09 release).
My resource's name is "Calendar", and I tried the call to FindControl with both the "Calendar" name and the "ResCalendar" name.
Here's my code:
protected void scheduleDisplay_FormCreated(object sender, SchedulerFormCreatedEventArgs e)
{
if (e.Container.Mode == SchedulerFormMode.AdvancedEdit ||
e.Container.Mode == SchedulerFormMode.AdvancedInsert)
{
Control panel = e.Container.FindControl("AdvancedControlsPanel") as Control;
Control resourceControlContainer = panel.FindControl("ResourceControls") as Control;
DropDownList calendarResourceDropDown = e.Container.FindControl("ResCalendar") as DropDownList;
if (calendarResourceDropDown == null) // this is from a different post
calendarResourceDropDown = resourceControlContainer.FindControl("ResCalendar") as DropDownList;
calendarResourceDropDown.Items.RemoveAt(0); // here it is still null
}
}
0
John Yoo
Top achievements
Rank 1
answered on 23 Jul 2009, 10:22 PM
I actually figured it out, it works with the ResCalendar, but the type of the control is not DropDownList but rather RadComboBox.
Never mind.
Never mind.
0
Hi John,
Yes, with Q2 2009 we have replaced the resour dropdownlist with RadComboBox. We might need to document this better.
All the best,
Peter
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Yes, with Q2 2009 we have replaced the resour dropdownlist with RadComboBox. We might need to document this better.
All the best,
Peter
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Dan Green
Top achievements
Rank 1
answered on 19 Feb 2013, 07:57 PM
I need to do this, but I am using the web service binding and OnFormCreated event is not fired at all.
0
Hello Dan,
Plamen
the Telerik team
I case of Web Service binding you can use onClientFormCreated event in order to get the client object of the appropriate resource RadCombobox in a similar way as is it is explained in this help article.
Hope this will be helpful.
Plamen
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.
0
Dan Green
Top achievements
Rank 1
answered on 28 Feb 2013, 06:40 PM
Following the example I have tried to remove the default item without any luck. Here is my code.
function clientFormCreated(sender, args) {
var mode = args.get_mode();
if (mode == Telerik.Web.UI.SchedulerFormMode.AdvancedInsert ||
mode == Telerik.Web.UI.SchedulerFormMode.AdvancedEdit) {
var repComboBox = $find($telerik.$("[id$='Form_ResRep']").attr("id"));
console.log(repComboBox.get_items().getItem(0).get_text());
repComboBox.get_items().removeAt(0);
console.log(repComboBox.get_items().getItem(0).get_text());
}
}
The fist console.log == "-" and the second one = "Connor Flynn", which is the first option in the list after the default value.
So it is removed, but it is not reflected in the UI, the list still contains the default value of "-".
var mode = args.get_mode();
if (mode == Telerik.Web.UI.SchedulerFormMode.AdvancedInsert ||
mode == Telerik.Web.UI.SchedulerFormMode.AdvancedEdit) {
var repComboBox = $find($telerik.$("[id$='Form_ResRep']").attr("id"));
console.log(repComboBox.get_items().getItem(0).get_text());
repComboBox.get_items().removeAt(0);
console.log(repComboBox.get_items().getItem(0).get_text());
}
}
The fist console.log == "-" and the second one = "Connor Flynn", which is the first option in the list after the default value.
So it is removed, but it is not reflected in the UI, the list still contains the default value of "-".
0
Hi Dan,
Hope this will be helpful.
Regards,
Plamen
the Telerik team
You need to set some time out when removing the item so that is performed after the default loading of resources is done. Here is the code that should work for you:
function
OnClientFormCreated(sender, args) {
var
mode = args.get_mode();
if
(mode == Telerik.Web.UI.SchedulerFormMode.AdvancedInsert ||
mode == Telerik.Web.UI.SchedulerFormMode.AdvancedEdit) {
var
repComboBox = $find($telerik.$(
"[id$='Form_ResRep']"
).attr(
"id"
));
setTimeout(
function
myfunction() {
repComboBox.get_items().removeAt(0);
}, 200);
}
}
Hope this will be helpful.
Regards,
Plamen
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.