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

how to add ResourceStyleMapping from code?

1 Answer 76 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Doug
Top achievements
Rank 1
Doug asked on 26 Apr 2017, 08:24 PM

first I have my RadScheduler in a page calling a webservice using a custom provider (MyDbSchedulerProvider)
I am adding dynamic category coloring to my appointments.
I was able to add them manually to the front code as

<ResourceStyles>
    <telerik:ResourceStyleMapping Type="Calendar" Key="cat1" Text="category 1" BackColor="#DEB887" BorderColor="#000000" />
    <telerik:ResourceStyleMapping Type="Calendar" Key="cat2" Text="category 2" BackColor="#000000" BorderColor="#FFFFFF" />
</ResourceStyles>

then in my provider code I tried a few things but only got this to work so far

Dim oResource As Resource
Select Case (i Mod 4)
    Case 0
        'apt.CssClass = "rsCategoryAqua"
        'apt.BackColor = Drawing.Color.Aqua
        'apt.ForeColor = Drawing.Color.Black
        oResource = New Resource("Calendar", "cat1", "category 1")
        apt.Resources.Add(oResource)
    Case 1
        'apt.CssClass = "rsCategoryBeige"
        'apt.BackColor = Drawing.Color.Beige
        'apt.ForeColor = Drawing.Color.Black
        oResource = New Resource("Calendar", "cat2", "category 2")
        apt.Resources.Add(oResource)
End Select

ok I tried to remove the code front tags and add instead in the page behind

RadScheduler1.ResourceStyles.Add(New ResourceStyleMapping("Calendar", "cat3", "category 3"))
RadScheduler1.ResourceStyles.Add(New ResourceStyleMapping("Calendar", "cat4", "category 4"))

^^ didn't work
I also tried this

RadScheduler1.Resources.Add(New Resource("Calendar", "cat1", "category 1"))

^^ didn't work
highest preference is to add these colorings only in the provider but if I need to I can also add them dynamically in my page vb code if needed.
I use the webservice to keep from doing any database calls in the page to slow down my page. it would help to have the coloring only in the provider (webservice call) also.

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 01 May 2017, 02:45 PM
Hi,

Can you try the following approach:

Codebehind:
ResourceStyleMapping mapping = new ResourceStyleMapping();
mapping.BackColor = System.Drawing.Color.Blue;
mapping.Type = "User";
mapping.Key = "10";
RadScheduler1.ResourceStyles.Add(mapping);

 


Regards,
Rumen
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Scheduler
Asked by
Doug
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or