Style by hidden resource/attribute

5 posts, 0 answers
  1. Ryan Baxter
    Ryan Baxter avatar
    6 posts
    Member since:
    Feb 2004

    Posted 30 Nov 2012 Link to this post

    Is there a way for me to style by a hidden resource/attribute?  Every time an event is written I also log which user enters it via a insert parameter that is assigned via page_load so the user never sees this field and its not part of the form.  I would assume I need to add it as a resource or attribute and then set the visibility to false and set the value to something if I want to make it work?
  2. Ryan Baxter
    Ryan Baxter avatar
    6 posts
    Member since:
    Feb 2004

    Posted 03 Dec 2012 Link to this post

    I was able to hide my attribute once I figured out I need to add "Attr" to the front of the field I set in the "CustomAttributeNames" field.  But now how would I go about looping thru all values and setting a color.  I dont see a "Get" function like there is for the resources ...

    EX:
    Protected Sub ResourceStyles()
            For Each res As Resource In RadScheduler1.Resources.GetResourcesByType("User")
                Dim resMapping As New ResourceStyleMapping()
                resMapping.Key = res.Key.ToString()
                resMapping.BackColor = RandomRGBColor()
     
                RadScheduler1.ResourceStyles.Add(resMapping)
            Next
        End Sub

  3. Plamen
    Admin
    Plamen avatar
    2954 posts

    Posted 04 Dec 2012 Link to this post

    Hi,

     
    The easiest way to achieve it is by using AppointmentDataBound server event as you mentioned you did in the other forum thread.

    Kind regards,
    Plamen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  4. Ryan Baxter
    Ryan Baxter avatar
    6 posts
    Member since:
    Feb 2004

    Posted 04 Dec 2012 Link to this post

    How do I get all the distinct values or do I need to loop thru all the appointments first?  The attributes dont have all the options that the resources do.
  5. Plamen
    Admin
    Plamen avatar
    2954 posts

    Posted 07 Dec 2012 Link to this post

    Hi,

     
    You don't have to loop all appointments because AppointmentDataBound is throwing for every one of them. Here is a sample code that will change the appointment color if its attribute is set with particular value:

    protected void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e)
       {
           if (e.Appointment.Attributes["Annotations"]=="red")
           {
               e.Appointment.BackColor = System.Drawing.Color.Red;
           }
           
           
       }

    Hope this will be helpful.
    Kind regards,
    Plamen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top