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

implementing colors in grouping in rad schedular

1 Answer 44 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
asif
Top achievements
Rank 1
asif asked on 14 Feb 2011, 01:21 PM
I am implementing telerik's radschedular and loading resources in it with grouping functionality.
i have multiple docotrs and i want to distingvished their data by different colors.

Is there any mapping field for colors in ResourceMappingInfo class to map colors from resources object
for better understanding i m attaching some part of my code over here


        For i As Integer = 0 To resourceNames.Length - 1
            Resources.Add(New PanaceaBuisnessLayer.AppointmentResource(resourceNames(i), i + 1))
            Resources(0).Color = Color.Black
   Resources(1).Color = Color.Red
        Next i

        Dim resourceMappingInfo As New ResourceMappingInfo()
        resourceMappingInfo.Id = "Id"
        resourceMappingInfo.Name = "Name"
resourceMappingInfo.Color= ??????

        dataSource.ResourceProvider.Mapping = resourceMappingInfo
        dataSource.ResourceProvider.DataSource = Resources

        RadSchdAppView.GroupType = GroupType.Resource
        RadSchdAppView.DataSource = dataSource

1 Answer, 1 is accepted

Sort by
0
Dobry Zranchev
Telerik team
answered on 17 Feb 2011, 10:04 AM
Hi asif,

Thank you for writing.

Here, it is imporant how you will represent the color in the data table - as a string or as something else. In addition, you should add custom mapping for the color property of the resource. The mapping for the color should be equal to the name of the field in the data table that represents the color. If the field in the data table has a string value, you should convert this value to color. For that purpose you should to create a converter callback functions that are set to the custom mapping object.
ResourceMappingInfo resourceMappingInfo = new ResourceMappingInfo();
SchedulerMapping colorMapping = new SchedulerMapping("Color", "Color");
colorMapping.ConvertToDataSource = new ConvertCallback(this.ConvertColorToDataSource);
colorMapping.ConvertToScheduler = new ConvertCallback(this.ConvertColorToScheduler);
 
resourceMappingInfo.Mappings.Add(colorMapping);
 
 
private object ConvertColorToScheduler(object obj)
{
    //return Color as an object
    return Color.White;
}
 
private object ConvertColorToDataSource(object obj)
{
    //return Color as a string
    return string.Empty;
}

In case that you have further question, feel free to write back.

Greetings,
Dobry Zranchev
the Telerik team
Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
Tags
General Discussions
Asked by
asif
Top achievements
Rank 1
Answers by
Dobry Zranchev
Telerik team
Share this question
or