1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / events calendar - different category colors ?

events calendar - different category colors ?

10 posts, 0 answered
  1. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    02 Apr 2009
    Link to this post
    hi

    i have 3.2 sp2

    i have an events calendar
    i have 2 events on one date
    both events are assigned to 2 different categories (catA, catB)

    i wish to have all CatA events show with a red background, and CatB events to show with a yellow background.
    is this possible?


    also, how do i have a small calendar like on this page?
    http://www.habitatsa.org/eventsCalendarNew.aspx

    thanks
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    03 Apr 2009
    Link to this post
    Hi Quade,

    The items in RadScheduler are links, so it will be difficult to set different css classes depending on the tagged item. The small calendar on the page is RadCalendar control which uses Web20 skin.
    Here is an old post that you may find useful blog-like_calendar_navigation

    All the best,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    03 Apr 2009
    Link to this post
    Thanks Ivan

    The requirement is to have a calendar to display the following

    Special events (red)
    Normal operating days (yellow)
    Closed (grey)

    Is there any way you can suggest to acheive this?
    Thanks
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    03 Apr 2009
    Link to this post
    Hello Quade,

    Here is a sample that demonstrates how to manage EventsScheduleView control.

    Steps.

    1.Override EventsScheduleView control
    2. Override LayoutTemplatePath
    3. Override InitializeControls
    4. Remove the existing event and create a new one for EventsSchedule.AppointmentCreated

    Here is the code:

    using System; 
    using System.Web.UI.WebControls; 
    using Telerik.Events; 
    using Telerik.Events.WebControls; 
     
    /// <summary> 
    /// Summary description for MyEventsScheduleView 
    /// </summary> 
    public class MyEventsScheduleView : EventsScheduleView 
        public MyEventsScheduleView() 
        { 
        } 
     
        // override template path. 
        public override string LayoutTemplatePath 
        { 
            get 
            { 
                if (string.IsNullOrEmpty(this.layoutTemplatePath)) 
                    this.layoutTemplatePath = "~/Sitefinity_3_6_1870_standard_ExternalTemplates/Sitefinity/ControlTemplates/Events/EventsScheduleView.ascx"
                return this.layoutTemplatePath; 
            } 
            set 
            { 
                this.layoutTemplatePath = value; 
            } 
        } 
         
        // override InitializeControls 
        protected override void InitializeControls(System.Web.UI.Control controlContainer) 
        { 
            //call base class 
            base.InitializeControls(controlContainer); 
            // create our own hanlder where we will add our implementation 
            this.EventsSchedule.AppointmentCreated += new Telerik.Web.UI.AppointmentCreatedEventHandler(MyEventsSchedule_AppointmentCreated); 
     
        } 
     
        void MyEventsSchedule_AppointmentCreated(object sender, Telerik.Web.UI.AppointmentCreatedEventArgs e) 
        { 
            // clear whatever the base handler may have done 
            e.Container.Controls.Clear(); 
     
            // create a new instance of EventsManager 
            // if there is an event created we customize it. 
            EventsManager eventsManager = new EventsManager("Events"); 
              
            // get events 
            IEvent _event = eventsManager.GetEvent(new Guid(e.Appointment.ID.ToString())); 
            // create a new label and set red color to the items 
            // example for getting tags 
            //IList listofTags = eventsManager.GetTags(); 
     
            Label test = new Label(); 
            test.Style.Add("color""red"); 
            // get the title 
            test.Text = _event.ContentItem.GetMetaData("Title").ToString(); 
            e.Container.Controls.Add(test); 
        } 
     
        private string layoutTemplatePath; 
     
     

    I hope this helps.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  5. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    17 Sep 2009
    Link to this post
    Thanks Ivan, i'll have a go at this
    I need to pick this back up again after a long pause!

    Also, I need to add functionality to define the open days and closed days
    I could do this as an event, however, they want the whole cell to change color if its open/closed, rather than just a span inside the cell

    e.g. its closed on christmas day, so the whole cell would be grey.

    how would i acheive this?

    Thanks
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    17 Sep 2009
    Link to this post
    Hello Quade,

    Please take a look at this article TimeSlotCreated event. Below is a sample code that illustrates changing the color of a RadScheduleler ( in our case we are inheriting from EventsScheduleView)

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using Telerik.Events.WebControls; 
    using Telerik.Web.UI; 
    using Telerik.Events; 
    using System.Web.UI.WebControls; 
     
    /// <summary> 
    /// Summary description for Class6 
    /// </summary> 
    public class Class6 : EventsScheduleView 
        public Class6() 
        { 
        } 
     
        public override string LayoutTemplatePath 
        { 
            get 
            { 
                return "~/Sitefinity/ControlTemplates/Events/EventsScheduleView.ascx"
            } 
        } 
     
        protected override void InitializeControls(System.Web.UI.Control controlContainer) 
        { 
            base.InitializeControls(controlContainer); 
            this.EventsSchedule.TimeSlotCreated += new TimeSlotCreatedEventHandler(EventsSchedule_TimeSlotCreated); 
            this.EventsSchedule.AppointmentCreated += new AppointmentCreatedEventHandler(EventsSchedule_AppointmentCreated); 
        } 
     
        void EventsSchedule_AppointmentCreated(object sender, AppointmentCreatedEventArgs e) 
        { 
            e.Container.Controls.Clear(); 
     
            EventsManager eventsManager = new EventsManager("Events"); 
            IEvent _event = eventsManager.GetEvent(new Guid(e.Appointment.ID.ToString())); 
            Label test = new Label(); 
            test.Style.Add("color""red"); 
            // get the title  
            test.Text = _event.ContentItem.GetMetaData("Title").ToString(); 
            e.Container.Controls.Add(test);  
        } 
     
        void EventsSchedule_TimeSlotCreated(object sender, TimeSlotCreatedEventArgs e) 
        { 
            if (ViewState["NextNSlots"] != null
            { 
                int nextNSlots = Int16.Parse(ViewState["NextNSlots"].ToString()); 
                if (nextNSlots > 0) 
                { 
                    e.TimeSlot.Control.BackColor = System.Drawing.Color.Red; 
                    nextNSlots--; 
                    ViewState["NextNSlots"] = nextNSlots; 
                } 
            } 
            foreach (Appointment a in e.TimeSlot.Appointments) 
            { 
                if (a.Subject == "test"
                { 
                    e.TimeSlot.Control.BackColor = System.Drawing.Color.Green; 
                    ViewState["NextNSlots"] = a.Duration.Ticks / e.TimeSlot.Duration.Ticks - 1; 
                } 
            } 
           
        } 
     
     
     

    You can also take a look at the following article which describes How to set different styles to appointments

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    05 Oct 2009
    Link to this post
    Hi ivan

    thanks for this, i've tried having a go at implementing your first example bit of code, but i've no idea how or where to start

    I dont suppose you have a working example of this do you?

    Thanks
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    05 Oct 2009
    Link to this post
    Hello Quade,

    The code I sent you is a working sample that shows how you can style the TimeSlots. You need to implement the code for your case.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  9. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    06 Oct 2009
    Link to this post
    thanks ivan

    sorry for the confusion, what i meant was i didn't understand how to implement this.
    i.e. do i need to create a new user control, or do i need to edit existing code and replace with your code? if so which file do i edit.

    thanks
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    06 Oct 2009
    Link to this post
    Hello Quade,

    As I see we discussed this  some posts ago:

    "1.Override EventsScheduleView control
    2. Override LayoutTemplatePath
    3. Override InitializeControls
    4. Remove the existing event and create a new one for EventsSchedule.AppointmentCreated"


    You cannot use a user control. You should create a custom control in App_Code folder or Class Library.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
10 posts, 0 answered