Hi,
I have successfully created a project with RadScheduler where I use a custom Appointment class (AllocationViewDataItem) and a custom Resource class (ExtendedResource). This project uses postbacks and a DataSource set in by calling a provider in Page_Load using the required parameters and setting the retrieved list of AllocationViewDataItems (custom appointments) as the DataSource of the scheduler.
The custom appointments (AllocationViewDataItems) contain a string property called Resource that contains the key of the resource they are related to.
The resources and appointments are connected by setting the ForeignKeyField on the ResourceType:
The scheduler uses the custom appointment class by defining these properties:
This works perfectly and the resources and allocations are shown as they should.
Now, I'd like to change the project so that the data is retrieved using web services because they constant postbacks are not too pretty. I have created a branch of the project that contains a web service that calls the same DataManager and returns a list of AllocationViewDataItems (just like the GetData method in the old Page_Load that was set as DataSource). However, the appointments are no longer matched with resources based on the ForeignKeyField of the ResourceType. No appointments are shown and when I hook into the OnClientAppointmentDataBound event I can see that the appointments are databound, but their collection of Resources is empty. Below is a dummy example of the web service methods (which does not work either):
The Scheduler defines the use of the web service and the AllocationViewDataItems as such:
The custom appointments are simply not connected to the resources so they are not shown. If I use AppointmentData instead and assigns a specific ResourceData object to the Resources property it works, but would mean that I would have to redo a quite a bit of code so I would prefer not to.
Is it not possible to use the ForeignKeyField to combine a custom Appointment class to resources when using Web Services to retrieve data?
Another issue is that I can't successfully use the Attributes property of the ResourceData class. When I add an item to the Attributes collection in the web service method it is not transfered to the Resource class created behind the scenes. I have checked this by adding an item to the Attributes collection in the web service method "GetResources" and then inspecting the Resource class retrieved in the OnResourceHeaderCreated event (here the Attribute collection is empty). See the two attached images. This is an issue as I need to transfer a custom URL property to the resource to make it clickable.
The attributes are successfully transfered from AppointmentData to the Appointment (adding attribute to AppointmentData object in web service method and retrieving the attribute value in OnClientAppointmentDataBound).
I hope you can help me with either of the two issues.
/Michael
I have successfully created a project with RadScheduler where I use a custom Appointment class (AllocationViewDataItem) and a custom Resource class (ExtendedResource). This project uses postbacks and a DataSource set in by calling a provider in Page_Load using the required parameters and setting the retrieved list of AllocationViewDataItems (custom appointments) as the DataSource of the scheduler.
var dataSource = DataManager.GetData(WebPart.ViewType, WebPart.DataFiltering, WebPart.ShowAllocationInLabel, selectedDate, numberOfWeeks, selectedRole);
Scheduler.DataSource = dataSource;
The custom appointments (AllocationViewDataItems) contain a string property called Resource that contains the key of the resource they are related to.
public
class
AllocationViewDataItem
{
public
int
Id {
get
;
set
; }
public
string
Resource {
get
;
set
; } //<------ This Property
public
DateTime Start {
get
;
set
; }
public
DateTime End {
get
;
set
; }
public
Color Color {
get
;
set
; }
public
string
CustomText {
get
;
set
; }
...
}
The resources and appointments are connected by setting the ForeignKeyField on the ResourceType:
var rType =
new
ResourceType("User") { ForeignKeyField =
"Resource"
};
Scheduler.ResourceTypes.Add(rType);
Scheduler.GroupBy = "User";
The scheduler uses the custom appointment class by defining these properties:
<
telerik:RadScheduler
runat
=
"server"
ID
=
"Scheduler"
DataStartField
=
"Start"
DataEndField
=
"End"
DataSubjectField
=
"CustomText"
DataKeyField
=
"Id"
...
>
This works perfectly and the resources and allocations are shown as they should.
Now, I'd like to change the project so that the data is retrieved using web services because they constant postbacks are not too pretty. I have created a branch of the project that contains a web service that calls the same DataManager and returns a list of AllocationViewDataItems (just like the GetData method in the old Page_Load that was set as DataSource). However, the appointments are no longer matched with resources based on the ForeignKeyField of the ResourceType. No appointments are shown and when I hook into the OnClientAppointmentDataBound event I can see that the appointments are databound, but their collection of Resources is empty. Below is a dummy example of the web service methods (which does not work either):
[WebMethod]
public
IEnumerable<AllocationViewDataItem> GetAppointments(ExtendedSchedulerInfo schedulerInfo)
{
return
new
List<AllocationViewDataItem>
{
new
AllocationViewDataItem
{
Id = 1,
Start = DateTime.Now,
End = DateTime.Now.AddHours(1),
CustomText =
"Subject"
,
Resource =
"test"
,
Color = Color.Red
}
};
}
[WebMethod]
public
IEnumerable<ResourceData> GetResources(ExtendedSchedulerInfo schedulerInfo)
{
var res =
new
List<ResourceData>
{
new
ResourceData
{
Key =
"test"
,
Type = "User",
Text =
"Test"
}
};
res[0].Attributes.Add(
"TestAttribute"
,
"testvalue"
);
return
res;
}
The Scheduler defines the use of the web service and the AllocationViewDataItems as such:
<
telerik:RadScheduler
runat
=
"server"
ID
=
"Scheduler"
DataStartField
=
"Start"
DataEndField
=
"End"
DataSubjectField
=
"CustomText"
DataKeyField
=
"Id"
...
>
<
WebServiceSettings
Path
=
"/_layouts/TestProject/ProjectAllocationDataService.asmx"
ResourcePopulationMode
=
"ServerSide"
/>
</
telerik:RadScheduler
>
The custom appointments are simply not connected to the resources so they are not shown. If I use AppointmentData instead and assigns a specific ResourceData object to the Resources property it works, but would mean that I would have to redo a quite a bit of code so I would prefer not to.
Is it not possible to use the ForeignKeyField to combine a custom Appointment class to resources when using Web Services to retrieve data?
Another issue is that I can't successfully use the Attributes property of the ResourceData class. When I add an item to the Attributes collection in the web service method it is not transfered to the Resource class created behind the scenes. I have checked this by adding an item to the Attributes collection in the web service method "GetResources" and then inspecting the Resource class retrieved in the OnResourceHeaderCreated event (here the Attribute collection is empty). See the two attached images. This is an issue as I need to transfer a custom URL property to the resource to make it clickable.
The attributes are successfully transfered from AppointmentData to the Appointment (adding attribute to AppointmentData object in web service method and retrieving the attribute value in OnClientAppointmentDataBound).
I hope you can help me with either of the two issues.
/Michael