how to add ResourceStyleMapping from code?

2 posts, 0 answers
  1. Doug
    Doug avatar
    104 posts
    Member since:
    Aug 2014

    Posted 26 Apr 2017 Link to this post

    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.

  2. Rumen
    Admin
    Rumen avatar
    14105 posts

    Posted 01 May 2017 Link to this post

    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.
Back to Top