Cuztomizing rows and cell

6 posts, 0 answers
  1. Marcin
    Marcin avatar
    5 posts
    Member since:
    Jul 2008

    Posted 01 Feb 2009 Link to this post

    Hi,
    i want to customize scheduler by changing style of cells. I want to do it dynamiclly. Etc i want some cells to be red other to be green. How can i access cells while control is loading to set cell style?

    Thanks
    Marcin
  2. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 03 Feb 2009 Link to this post

    Hello Marcin,

    RadScheduler is still a new addition to the RadControls for WinForms suite and does not support that functionality yet. However this is something that we will most probably add in a future release, so any feedback is most welcome.
     
    If you share with us more details about your case and what it is that you want to accomplish, we could even tell you what will the time frame for such functionality be.
     

    Sincerely yours,
    Jordan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Marcin
    Marcin avatar
    5 posts
    Member since:
    Jul 2008

    Posted 03 Feb 2009 Link to this post

    Hi,
    I want to store some timeframes (start date and enddate) in db. This timeframes will be created in different scheduler. Next i want to show somehow this timeframes in different scheduler. But it should not be editable it should be something like background with some text like "please create appointment in this area". So i need to dynamiclly create cell background for scheduler (etc in load event). It's strange that i cannot access cell from scheduler but i can access it from event "cell clicked" and change background and background text. I understand that it's new control and i hope that in next release it will improved becaouse it can be really usefull.

    Thanks
    Marcin 
  4. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 06 Feb 2009 Link to this post

    Hello Marcin,

    I see your point.
    Currently RadScheduler can show work time hours in different color depending on the theme that is currently applied. These hours can be set like in the code below:
    SchedulerDayView dayView = this.radScheduler.GetDayView(); 
    if (dayView != null
        dayView.WorkTime = new TimeInterval(TimeSpan.FromHours(10.0), TimeSpan.FromHours(16.0)); 

    However, these hours are the same for each day, and may be you want them to be different for each day.
    We will be looking for a way to allow that.

    The part with the "please create appointment in this area" text can be difficult to implement depending on how you want to show it. If you want to span that text over all colored cells because you will have to determine where to position it.

    Kind regards,
    Jordan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Victor
    Victor avatar
    31 posts
    Member since:
    Aug 2016

    Posted 23 Sep 2019 in reply to Jordan Link to this post

    Hi,

    It has been 10 years since the last reaction on this post, so maybe something has changed :

    I have a availability table which stores the availability of a resource with the following fields : Resource, Start-datetime, End-datetime.

    In the timeline view I want to give the cells which are in an available 'timeslot' to get a different background color (See attached image as example). I know how I could do it, but I am afraid of performance loss if I have to check every drawn cell against the records in the database.

     

    What would be the best way to implement this? Should I use the cellpaint event? or the cellformatting? or is there another solution? Scheduler Cell Containers? But how?

    How can I get the corresponding resource of a cell?

    I hope you can point me in the right direction

     

    Kind regards

    Victor

     

  6. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3957 posts

    Posted 24 Sep 2019 Link to this post

    Hello, Victor,   

    According to the provided information, it seems that you are using RadScheduler grouped by resources in Timeline view. In order to customize the scheduler cells in different colors, the CellFormatting event is the appropriate way for achieving this goal. However, it is not necessary to extract the resources information each time the event is fired. This will lead to considerable performance slow-down since the CellFormatting event is expected to be fired a lot of time. You need to extract the information about the working hours of a resource just once and store it into an appropriate data structure. 

    I have prepared a sample project demonstrating how to achieve the following different coloring considering the resource's range of availability:

            Dictionary<string, Range> resourcesTimeRanges = new Dictionary<string, Range>();
    
            public class Range
            {
                public int Start { get; set; }
    
                public int End { get; set; }
    
                public Range(int start, int end)
                {
                    this.Start = start;
                    this.End = end;
                }
            }
    
            public RadForm1()
            {
                InitializeComponent();
                Random rand = new Random();
                int start = 0;
                Color[] colors = new Color[]
                {
                    Color.LightBlue, Color.LightGreen, Color.LightYellow,
                    Color.Red, Color.Orange, Color.Pink, Color.Purple, Color.Peru, Color.PowderBlue
                };
                string[] names = new string[]
                {
                    "Alan Smith", "Anne Dodsworth",
                    "Boyan Mastoni", "Richard Duncan", "Maria Shnaider"
                };
                for (int i = 0; i < names.Length; i++)
                {
                    Resource resource = new Resource();
                    resource.Id = new EventId(i);
                    resource.Name = names[i];
                    resource.Color = colors[i];
                    start = rand.Next(7, 11);
                    resourcesTimeRanges.Add(resource.Name, new Range(start,start + rand.Next(1, 7)));
                    this.radScheduler1.Resources.Add(resource);
                }
                this.radScheduler1.CellFormatting += radScheduler1_CellFormatting;
                this.radScheduler1.GroupType = GroupType.Resource;
                this.radScheduler1.ActiveView.ResourcesPerView = this.radScheduler1.Resources.Count;
                this.radScheduler1.ActiveViewType = SchedulerViewType.Timeline;
    
                SchedulerTimelineView timelineView = this.radScheduler1.GetTimelineView();
    
                Timescales scale = Timescales.Hours;
                timelineView.ShowTimescale(scale);
                SchedulerTimescale currentScaling = timelineView.GetScaling();
                currentScaling.DisplayedCellsCount = 12;
                timelineView.StartDate = DateTime.Today.AddHours(7);
            }
    
            private void radScheduler1_CellFormatting(object sender, SchedulerCellEventArgs e)
            {
                Resource r = e.CellElement.View.GetResource() as Resource;
                if (r != null && resourcesTimeRanges.ContainsKey(r.Name) &&
                    e.CellElement.Date.Hour >= resourcesTimeRanges[r.Name].Start &&
                    e.CellElement.Date.Hour <= resourcesTimeRanges[r.Name].End)
                {
                    e.CellElement.DrawFill = true;
                    e.CellElement.GradientStyle = GradientStyles.Solid;
                    e.CellElement.BackColor = Color.Red;
                }
                else
                {
                    e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
                    e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
                    e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
                }
            }

    I have also attached my sample project for your reference.

    I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top