Basically what I'm trying to accomplish with a custom AdvancedForm, is that when the user changes one dropdown value, it will repopulate another. I have a Client dropdown, and clients have services assigned to them. When the client changes, I need to pull in the appropriate services they have based on what comes back from the database.
Currently I'm using ResourceControl.ascx which is just the single drop-down list. When the resources are initially being populated with the RadScheduler, I set them all to Available = false to hide them until the Client resource's RadComboBox index changes.
I am currently using the following code to wire up the desired ComboBox on my AdvancedForm
I've hacked together a solution that partially works, but I am unable to use Attributes or the properties of a Resource
It's involved taking some of the methods from the various controls and making them Public or copying them and just seems really messy.
Is there ANY way this can be accomplished in a clean manner?
Currently I'm using ResourceControl.ascx which is just the single drop-down list. When the resources are initially being populated with the RadScheduler, I set them all to Available = false to hide them until the Client resource's RadComboBox index changes.
I am currently using the following code to wire up the desired ComboBox on my AdvancedForm
RadComboBox cbClient = AdvancedForm.FindControl(
"ResClient"
).FindControl(
"ResourceValue"
)
as
RadComboBox;
//RadComboBox cbClient = e.Container.FindControl("ResClient") as RadComboBox; <- THIS DOESN'T WORK
if
(cbClient !=
null
)
{
cbClient.AutoPostBack =
true
;
cbClient.SelectedIndexChanged +=
new
RadComboBoxSelectedIndexChangedEventHandler(cbClient_SelectedIndexChanged);
}
I've hacked together a solution that partially works, but I am unable to use Attributes or the properties of a Resource
protected
void
cbClient_SelectedIndexChanged(
object
sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
//RadComboBox rcb = (RadComboBox)sender;
//RadSchedulerAdvancedFormResourceControl ctrl = (RadSchedulerAdvancedFormResourceControl)rcb.Parent;
//Gets the resource control contained within the advanced form
RadSchedulerAdvancedFormResourceControl resourceControl = AdvancedForm.FindControl(
"ResService"
)
as
RadSchedulerAdvancedFormResourceControl;
//Grabs the ServiceType combo box for binding
RadComboBox cbServiceType = AdvancedForm.FindControl(
"ResService"
).FindControl(
"ResourceValue"
)
as
RadComboBox;
//Casts the sender as a RadComboBox, this was the client dropdown
//RadComboBox cbClient = (RadComboBox)sender;
//Declare an instance of a ResourceControl to deserialize the key selected
RadSchedulerAdvancedFormResourceControl resControl =
new
RadSchedulerAdvancedFormResourceControl();
//Will rebind the ServiceType dropdown based on who was selected
//Since items bound to the control can be objects, they need to be serialized/deserialized
object
resourceKey =
null
;
if
(e.Value !=
"NULL"
)
{
resourceKey = DeserializeResourceKey(e.Value);
//Access the provider
LaSchedulerProvider provider = PopulateProvider();
//Bind
cbServiceType.Items.Clear();
//cbServiceType.DataSource = provider.LoadClientServices(Convert.ToInt32(resourceKey), AdvancedForm.Start, AdvancedForm.End);
//cbServiceType.DataValueField = "Key";
//cbServiceType.DataTextField = "Text";
//cbServiceType.DataBind();
foreach
(Resource clientResource
in
provider.LoadClientServices(Convert.ToInt32(resourceKey), AdvancedForm.Start, AdvancedForm.End))
{
clientResource.Available =
true
;
cbServiceType.Items.Add(
new
RadComboBoxItem(clientResource.Text, SerializeResourceKey(clientResource.Key)));
}
cbServiceType.Items.Insert(0,
new
RadComboBoxItem(
"-"
,
"NULL"
));
}
else
{
resourceKey =
""
;
cbServiceType.Items.Clear();
cbServiceType.Items.Insert(0,
new
RadComboBoxItem(
"-"
,
"NULL"
));
}
It's involved taking some of the methods from the various controls and making them Public or copying them and just seems really messy.
Is there ANY way this can be accomplished in a clean manner?