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

Resource Grouping and Custom Appointment class

5 Answers 146 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Anastasios
Top achievements
Rank 1
Anastasios asked on 12 May 2010, 02:03 PM
I cant get my custom appointment class to be related with my resources.
I follow the forum examples about custom appointment class.

In the form  I do the following:
public frmScheduler() 
        { 
            InitializeComponent(); 
 
            this.schedQuickTasks.AppointmentFactory = new QuickTaskFactory(); 
             
            this.schedQuickTasksBindingSource.EventProvider.AppointmentFactory = schedQuickTasks.AppointmentFactory;       
            #region QuickTask custom dialog mappings 
            AppointmentMappingInfo appointmentMappingInfo = schedQuickTasksBindingSource.EventProvider.Mapping as AppointmentMappingInfo; 
            appointmentMappingInfo.Mappings.Add(new SchedulerMapping("ID""ID")); 
            appointmentMappingInfo.Mappings.Add(new SchedulerMapping("ProjectID""Project_ID")); 
            appointmentMappingInfo.Mappings.Add(new SchedulerMapping("Description""Description")); 
            appointmentMappingInfo.Mappings.Add(new SchedulerMapping("TaskTypeID""TaskType_ID")); 
            appointmentMappingInfo.Mappings.Add(new SchedulerMapping("CustomerDeadline""CustomerDeadline")); 
            appointmentMappingInfo.Mappings.Add(new SchedulerMapping("OurDeadline""OurDeadline")); 
            appointmentMappingInfo.Mappings.Add(new SchedulerMapping("UserID""User_ID")); 
            appointmentMappingInfo.Mappings.Add(new SchedulerMapping("CustomerImportance""CustomerImportance")); 
            appointmentMappingInfo.Mappings.Add(new SchedulerMapping("OurImportance""OurImportance")); 
            appointmentMappingInfo.Mappings.Add(new SchedulerMapping("OrderForUser""OrderForUser")); 
            appointmentMappingInfo.Mappings.Add(new SchedulerMapping("TimeEstimation""TimeEstimation")); 
            appointmentMappingInfo.Mappings.Add(new SchedulerMapping("Comments""Comments")); 
            appointmentMappingInfo.Mappings.Add(new SchedulerMapping("TaskStatus""Status")); 
            appointmentMappingInfo.Mappings.Add(new SchedulerMapping("DateEntered""DateEntered")); 
            appointmentMappingInfo.Mappings.Add(new SchedulerMapping("AssignerID""AssignerUser_ID")); 
            appointmentMappingInfo.Mappings.Add(new SchedulerMapping("Start""DateEntered")); 
             
            appointmentMappingInfo.ResourceId = "User_ID"
            #endregion 
            #region Resources custom mapping 
            ResourceMappingInfo resourceMappingInfo = new ResourceMappingInfo(); 
            resourceMappingInfo.Id = "User_ID"
            resourceMappingInfo.Name = "FullName"
            schedQuickTasksBindingSource.ResourceProvider.Mapping = resourceMappingInfo; 
            #endregion 
 
        } 

the Appointment class is the "QuickTask" and  the Users are the resources.
If I disable resource grouping the Appointments are displayed.If I enabled it,only the resources are shown.
Am I missing something?

Thank you very much for your time





5 Answers, 1 is accepted

Sort by
0
Anastasios
Top achievements
Rank 1
answered on 13 May 2010, 12:07 PM
Problem solved.
The Resource field mapping was missing

0
Dobry Zranchev
Telerik team
answered on 13 May 2010, 12:25 PM
Hi Anastasios,

Thank you for contacting us.

Please take a look on our binding example which is installed with our product (Demos -> Scheduler -> Binding example). This example shows how to use mappings. In addition, please review the much updated documentation, namely the following topic: Using the DataSource property

The problem I see in your code is that you try to create custom mappings for items that already exist. For example mapping for Start should not be:
 
appointmentMappingInfo.Mappings.Add(new SchedulerMapping("Start", "DateEntered"));
 
but
 
appointmentMappingInfo.Start = "DateEntered";
 
I hope this will help you.

If you have additional questions feel free to ask.

Kind regards,
Dobry Zranchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Anastasios
Top achievements
Rank 1
answered on 16 May 2010, 04:53 PM
Thank you again Dobry

I have made just a small test application with no custom mapping to see if it works.
My resources and appointments tables have one to many relation.One resource belongs to many appointments.
So the Resource table has these fields: ResourceID,Name
and the Appointments table :     StartDate,Description,EndDate,ResourceID.
I have set the mappings with the SchedulerDataBindingSource smart tag.
I saw in your help documentation that when we have two table relation(one to many),the Resources field should not be set to nothing.So I did.

The problem is the following: If I enable resource grouping I see only the resources with no appointments.
If I disable the resource grouping,I can see the appointments.

0
Accepted
Dobry Zranchev
Telerik team
answered on 18 May 2010, 10:33 PM
Hello Anastasios,

Thank you for writing.

I tried your case and I found that you need to create converter callback methods that convert the database type int to EventID and vise versa. In your scheduler add the  following mapping for the ResourceId in the AppointmentMapping info object:
 
SchedulerMapping schedulerMappingResourceId = appointmentMappingInfo1.FindBySchedulerProperty("ResourceId");
schedulerMappingResourceId.ConvertToDataSource = new ConvertCallback(this.ConvertResouceIdToDataSourceCallback);
schedulerMappingResourceId.ConvertToScheduler = new ConvertCallback(this.ConvertResouceIdToSchedulerCallback);
 
private object ConvertResouceIdToDataSourceCallback(object obj)
{
    if (obj != null)
        return (int)((EventId)obj).KeyValue;
 
    return obj;
}
 
private object ConvertResouceIdToSchedulerCallback(object obj)
{
    return new EventId(obj);
}
 
If you have problems, please take a look at the attachment. I think it will help you.

I you have other questions feel free to contact us.

Kind regards,
Dobry Zranchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Anastasios
Top achievements
Rank 1
answered on 19 May 2010, 08:40 AM
It works!
Thank you very much for your help Dobry.
Tags
Scheduler and Reminder
Asked by
Anastasios
Top achievements
Rank 1
Answers by
Anastasios
Top achievements
Rank 1
Dobry Zranchev
Telerik team
Share this question
or