Resource Grouping and Custom Appointment class

6 posts, 1 answers
  1. Anastasios
    Anastasios avatar
    16 posts
    Member since:
    May 2010

    Posted 12 May 2010 Link to this post

    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





  2. Anastasios
    Anastasios avatar
    16 posts
    Member since:
    May 2010

    Posted 13 May 2010 Link to this post

    Problem solved.
    The Resource field mapping was missing

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 13 May 2010 Link to this post

    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.
  5. Anastasios
    Anastasios avatar
    16 posts
    Member since:
    May 2010

    Posted 16 May 2010 Link to this post

    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.

  6. Answer
    Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 18 May 2010 Link to this post

    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.
  7. Anastasios
    Anastasios avatar
    16 posts
    Member since:
    May 2010

    Posted 19 May 2010 Link to this post

    It works!
    Thank you very much for your help Dobry.
Back to Top
UI for WinForms is Visual Studio 2017 Ready