Hi, I just realized that I posted a question last night into the wrong location:
http://www.telerik.com/community/forums/wpf/scheduler/dynamic-resources-in-codebehind.aspx
For some reason I'm having a hard time applying ResourceTypes and ResourceStyles to the RadScheduler dynamically. I'm sure I'm missing something small, and yet I can't catch it. Please take a look at my code and maybe you can point me in the right direction.
When the sheduler is done databinding, I can step into the code and see that the Resources collection of the RadScheduler has been populated, but if I step into the AppointmentDataBound event, none of the appointments show any resources assigned, even though the AssignedTo column is definitely populated in the datatable. I'm also open to populating the Resouces collection manually, as long as it's done programmatically. I've looked at probably all your demo samples, but somehow still missed the solution. Thank you so much!
Dasha.
http://www.telerik.com/community/forums/wpf/scheduler/dynamic-resources-in-codebehind.aspx
For some reason I'm having a hard time applying ResourceTypes and ResourceStyles to the RadScheduler dynamically. I'm sure I'm missing something small, and yet I can't catch it. Please take a look at my code and maybe you can point me in the right direction.
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!IsPostBack)
{
objDS = GetDataSet();
SetupResources();
RadScheduler.DataSource = objDS.Tables[0];
RadScheduler.DataBind();
}
}
private
void
SetupResources()
{
ResourceType resType =
new
ResourceType();
resType.ForeignKeyField =
"AssignedTo"
;
resType.DataSource = objDS.Tables[
"table2"
];
resType.KeyField =
"id"
;
resType.Name =
"User"
;
resType.TextField =
"UserName"
;
RadScheduler.ResourceTypes.Add(resType);
ResourceStyleMapping rsm =
new
ResourceStyleMapping();
rsm.ApplyCssClass =
"rsCategoryPink"
;
rsm.Text =
"Dasha"
;
rsm.Type =
"User"
;
RadScheduler.ResourceStyles.Add(rsm);
rsm =
new
ResourceStyleMapping();
rsm.ApplyCssClass =
"rsCategoryGreen"
;
rsm.Text =
"Joe"
;
rsm.Type =
"User"
;
RadScheduler.ResourceStyles.Add(rsm);
rsm =
new
ResourceStyleMapping();
rsm.ApplyCssClass =
"rsCategoryOrange"
;
rsm.Text =
"Adam"
;
rsm.Type =
"User"
;
RadScheduler.ResourceStyles.Add(rsm);
}
This is the xml data that's converted into a dataset:
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
dataSet
>
<
table1
>
<
id
>1</
id
>
<
Title
>Task1</
Title
>
<
Date
>08/07/2010</
Date
>
<
End
>08/17/2010</
End
>
<
AssignedTo
>Dasha</
AssignedTo
>
<
Status
>Completed</
Status
>
<
Room
>Library</
Room
>
</
table1
>
<
table1
>
<
id
>2</
id
>
<
Title
>Task 2</
Title
>
<
Date
></
Date
>
<
End
>08/07/2010</
End
>
<
AssignedTo
>Dasha</
AssignedTo
>
<
Status
>Completed</
Status
>
<
Room
>Office</
Room
>
</
table1
>
<
table1
>
<
id
>3</
id
>
<
Title
>Task 3</
Title
>
<
Date
>08/18/2010</
Date
>
<
End
>08/18/2010</
End
>
<
AssignedTo
>Adam</
AssignedTo
>
<
Status
>Completed</
Status
>
<
Room
>Library</
Room
>
</
table1
>
<
table1
>
<
id
>4</
id
>
<
Title
>Task 4</
Title
>
<
Date
></
Date
>
<
End
>08/08/2010</
End
>
<
AssignedTo
>Joe</
AssignedTo
>
<
Status
>Completed</
Status
>
<
Room
>Library</
Room
>
</
table1
>
<
table2
>
<
id
>1</
id
>
<
UserName
>Dasha</
UserName
>
<
UserAge
>28</
UserAge
>
<
UserOccupation
>Plumber</
UserOccupation
>
</
table2
>
<
table2
>
<
id
>2</
id
>
<
UserName
>Joe</
UserName
>
<
UserAge
>30</
UserAge
>
<
UserOccupation
>IT Professional</
UserOccupation
>
</
table2
>
<
table2
>
<
id
>3</
id
>
<
UserName
>Adam</
UserName
>
<
UserAge
>33</
UserAge
>
<
UserOccupation
>Manager</
UserOccupation
>
</
table2
>
<
table2
>
<
id
>4</
id
>
<
UserName
>Michael</
UserName
>
<
UserAge
>30</
UserAge
>
<
UserOccupation
>Developer</
UserOccupation
>
</
table2
>
</
dataSet
>
When the sheduler is done databinding, I can step into the code and see that the Resources collection of the RadScheduler has been populated, but if I step into the AppointmentDataBound event, none of the appointments show any resources assigned, even though the AssignedTo column is definitely populated in the datatable. I'm also open to populating the Resouces collection manually, as long as it's done programmatically. I've looked at probably all your demo samples, but somehow still missed the solution. Thank you so much!
Dasha.