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

Adding Resources Server Side

1 Answer 60 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Chad
Top achievements
Rank 1
Chad asked on 24 Sep 2008, 03:29 PM
I need to be able to add a varying number of resources that utilize varying types of controls (checkbox, dropdownlist, etc).

The problem is that I cannot create an AdvancedEdit/Insert template using an aspx page, and need to do it on the server side.

So far I can add a resource with the following...

aResource =

new ResourceType("Calendar Color");

aResource.DataSource = GetColors();  // a DataTable with 7 colors and 1 column - "Color"

aResource.KeyField =

"Color";

aResource.TextField =

"Color";

aResource.ForeignKeyField =

"RadSchedulerColor"// the field in the Scheduler datasource containing 1 of  the 7 color values

theScheduler.ResourceTypes.Add(aResource);


The problem is that I want to add new resources with different controls, like a checkbox or a radiobutton. Then I want to be able to set the value based on the Scheduler's datasource. Currently this does not link to the Scheduler so the resource has no default value. I tried to override the OnFormCreated method:

void theScheduler_FormCreated(object sender, SchedulerFormCreatedEventArgs e)

{

if (e.Container.Mode == SchedulerFormMode.AdvancedInsert || e.Container.Mode == SchedulerFormMode.AdvancedEdit)

{

DropDownList colors = (DropDownList)e.Container.FindControl("Calendar Color");

colors.SelectedValue =

"Red";

colors.Width =

new Unit(100, UnitType.Percentage);

}

}


This only increased the width, it doesn't set the SelectedValue. Am I doing this right? Is what I'm trying to do possible without creating a custom UserControl with aspx elements?

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 26 Sep 2008, 03:22 PM
Hello Chad,

If you want to use controls other than the default dropdownlist control to display resources, you should use the Customizing the advanced template example. I understand that you would rather not resort to using user controls, but unfortunately this is the only way to achieve the disired functionality.


Cheers,
Peter
the Telerik team

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