Custom Resource Group Header Styles?

8 posts, 0 answers
  1. Jeff
    Jeff avatar
    48 posts
    Member since:
    Apr 2012

    Posted 17 Jun 2014 Link to this post

    I need to modify the style of the group header but can't seem to do it. I can modify the font, but it also seems to modify the font of the appointments as well.
    Dim SchedElement As SchedulerDayViewGroupedByResourceElement = RadScheduler1.GetDayView.Scheduler.SchedulerElement.ViewElement
    SchedElement.Font = New Font("Segoe UI", 10, FontStyle.Regular, GraphicsUnit.Point)
    SchedElement.ForeColor = Color.White
    SchedElement.ResourceHeaderHeight = 35
    SchedElement.ResourcesHeader.BackColor = Color.FromArgb(0, 159, 60)
    SchedElement.ResourcesHeader.BackColor2 = Color.FromArgb(0, 159, 60)
     
    Anything that sets a "ResourceHeader" doesn't seem to do what I am expecting. The attached picture shows the header I am trying to modify as well as what RadControlSpy says about it.
  2. Ralitsa
    Admin
    Ralitsa avatar
    181 posts

    Posted 19 Jun 2014 Link to this post

    Hi Jeff,

    Thank you for contacting us. 

    If you want to change the color of resource, you need to change the Color of one resource or all resources. Please take a look at the following code example: 

    1. Change the color of one resource: 
    Me.RadScheduler1.Resources(1).Color = Color.BlueViolet

    2. Change the color of all resources:    
    Dim colors() As Color = {Color.LightBlue, Color.LightGreen, Color.LightYellow, Color.Red, Color.Orange, Color.Pink, Color.Purple, Color.Peru, Color.PowderBlue}
     
            Dim names() As String = {"Alan Smith", "Anne Dodsworth", "Boyan Mastoni", "Richard Duncan", "Maria Shnaider"}
     
            For i As Integer = 0 To names.Length - 1
                Dim resource As New Telerik.WinControls.UI.Resource()
                resource.Id = New EventId(i)
                resource.Name = names(i)
                'set to each resource different color
                'resource.Color = colors(i)
                'set to each resource one color
                resource.Color = Color.FromArgb(0, 159, 60)
                Me.RadScheduler1.Resources.Add(resource)
            Next i

    I attached a sample demo project which demonstrates you how to change the color of resource. 

    Regards,
    Ralitsa
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. Alejandro
    Alejandro avatar
    9 posts
    Member since:
    Jul 2012

    Posted 12 Jun in reply to Ralitsa Link to this post

    When RadScheduler loads it works but when i save the changes with this code (code in the bottom) I lose my styles. How can i keep them? (View Attachment Photo):

    01.YDS_CitasDataSet.AppointmentsResourcesDataTable deletedRelationRecords = yDS_CitasDataSet.AppointmentsResources.GetChanges(DataRowState.Deleted)    as YDS_CitasDataSet.AppointmentsResourcesDataTable;
    02.YDS_CitasDataSet.AppointmentsResourcesDataTable newRelationRecords = this.yDS_CitasDataSet.AppointmentsResources.GetChanges(DataRowState.Added) as YDS_CitasDataSet.AppointmentsResourcesDataTable;
    03.YDS_CitasDataSet.AppointmentsResourcesDataTable modifiedRelationRecords = this.yDS_CitasDataSet.AppointmentsResources.GetChanges(DataRowState.Modified) as YDS_CitasDataSet.AppointmentsResourcesDataTable;
    04.YDS_CitasDataSet.AppointmentsDataTable newAppointmentRecords = this.yDS_CitasDataSet.Appointments.GetChanges(DataRowState.Added) as YDS_CitasDataSet.AppointmentsDataTable;
    05.YDS_CitasDataSet.AppointmentsDataTable deletedAppointmentRecords = this.yDS_CitasDataSet.Appointments.GetChanges(DataRowState.Deleted) as YDS_CitasDataSet.AppointmentsDataTable;
    06.YDS_CitasDataSet.AppointmentsDataTable modifiedAppointmentRecords = this.yDS_CitasDataSet.Appointments.GetChanges(DataRowState.Modified) as YDS_CitasDataSet.AppointmentsDataTable;
    07.try
    08.{
    09.if (newAppointmentRecords != null)
    10.{
    11.    Dictionary<int, int> newAppointmentIds = new Dictionary<int, int>();
    12.    Dictionary<object, int> oldAppointmentIds = new Dictionary<object, int>();
    13.    for (int i = 0; i < newAppointmentRecords.Count; i++)
    14.    {
    15.        oldAppointmentIds.Add(newAppointmentRecords[i], newAppointmentRecords[i].ID);
    16.    }
    17.    appointmentsAdapter.Update(newAppointmentRecords);
    18.    for (int i = 0; i < newAppointmentRecords.Count; i++)
    19.    {
    20.        newAppointmentIds.Add(oldAppointmentIds[newAppointmentRecords[i]], newAppointmentRecords[i].ID);
    21.    }
    22.    if (newRelationRecords != null)
    23.    {
    24.        for (int i = 0; i < newRelationRecords.Count; i++)
    25.        {
    26.            newRelationRecords[i].AppointmentID = newAppointmentIds[newRelationRecords[i].AppointmentID];
    27.        }
    28.    }
    29.}
    30.if (deletedRelationRecords != null)
    31.{
    32.    appointmentsResourcesAdapter.Update(deletedRelationRecords);
    33.}
    34.if (deletedAppointmentRecords != null)
    35.{
    36.    appointmentsAdapter.Update(deletedAppointmentRecords);
    37.}
    38.if (modifiedAppointmentRecords != null)
    39.{
    40.    appointmentsAdapter.Update(modifiedAppointmentRecords);
    41.}
    42.if (newRelationRecords != null)
    43.{
    44.    appointmentsResourcesAdapter.Update(newRelationRecords);
    45.}
    46.if (modifiedRelationRecords != null)
    47.{
    48.    appointmentsResourcesAdapter.Update(modifiedRelationRecords);
    49.}
    50.this.yDS_CitasDataSet.AcceptChanges();
    51. 
    52.}
    53.catch (Exception ex)
    54.{
    55.MessageBox.Show(string.Format("An error occurred during the update process:\n{0}", ex.Message));
    56.}
    57.finally
    58.{
    59.if (deletedRelationRecords != null)
    60.{
    61.    deletedRelationRecords.Dispose();
    62.}
    63.if (newRelationRecords != null)
    64.{
    65.    newRelationRecords.Dispose();
    66.}
    67.if (modifiedRelationRecords != null)
    68.{
    69.    modifiedRelationRecords.Dispose();
    70.}
    71.}
    72.lblStatus.Text = "Updated scheduler at " + DateTime.Now.ToString();
  4. Dess
    Admin
    Dess avatar
    1900 posts

    Posted 13 Jun Link to this post

    Hello Alejandro, 

    Thank you for writing.  

    When you save the changes to your database, it is not supposed to change the view element. However, if you refresh the SchedulerElement some of the applied changes may be lost. That is why I would recommend you to apply the changes after the RadScheduler is refreshed. Thus, you will ensure that the design will remain the same. If you are still experiencing any further difficulties, feel free to submit a support ticket where you can provide a sample project demonstrating the problem.

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Progress Telerik
    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.
  5. Alejandro
    Alejandro avatar
    9 posts
    Member since:
    Jul 2012

    Posted 13 Jun in reply to Dess Link to this post

    Hi Again.

    I tried to figure out the problem but I didn't find where occurs the refreshing method, I tried to submit a support ticket but I'm not the owner of the license. but I make a sample project with the problem, you can get from here: Sample Project in this file Iattached the full project and the sample database with only Radscheduler form and the mentioned behaviour. Can you help me?

  6. Dess
    Admin
    Dess avatar
    1900 posts

    Posted 14 Jun Link to this post

    Hello Alejandro, 

    Thank you for writing back. 

    Please ask the purchase holder to add you as a License Developer to the purchase. This will give you full access to the products your company has purchased, to our downloads section, and to our support ticketing system.

    I managed to replicate the described problem with the provided sample project. In order to keep the visual settings after saving the changes to your database you can use the following code snippet:
    private void BTN_Save_Click(object sender, EventArgs e)
    {
        this.Save();
        FormatUI();
        this.radScheduler1.SchedulerElement.RefreshViewElement();
        SchedulerDayViewGroupedByResourceElement headerElement = this.radScheduler1.SchedulerElement.ViewElement as SchedulerDayViewGroupedByResourceElement;
        headerElement.ResourceHeaderHeight = 135;
     
        RadMessageBox.Show(new Form() { TopMost = true, StartPosition = FormStartPosition.CenterScreen },
            "Information Saved.", "Aviso", MessageBoxButtons.OK, RadMessageIcon.Info, MessageBoxDefaultButton.Button1);
    }

    I hope this information helps. If you have any additional questions, please let me know. 

    Regards,
    Dess
    Progress Telerik
    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.
  7. Alejandro
    Alejandro avatar
    9 posts
    Member since:
    Jul 2012

    Posted 14 Jun in reply to Dess Link to this post

    Thank you Dess. It works. As an Add-on and only for the people who will ask the same in the future. We have to establish the view parameters again like it follows :
    private void BTN_Save_Click(object sender, EventArgs e)
           {
               this.Save();
               FormatUI();
               this.radScheduler1.SchedulerElement.RefreshViewElement();
               this.radScheduler1.GetDayView().RangeFactor = ScaleRange.QuarterHour;
               this.radScheduler1.GetDayView().ShowAllDayArea = false;
               this.radScheduler1.GetDayView().WorkTime.Start = new TimeSpan(9, 0, 0);
               this.radScheduler1.GetDayView().WorkTime.End = new TimeSpan(19, 0, 0);
               SchedulerDayViewGroupedByResourceElement dayView = this.radScheduler1.SchedulerElement.ViewElement as SchedulerDayViewGroupedByResourceElement;
               dayView.ScrollToWorkHours();
               SchedulerDayViewGroupedByResourceElement headerElement = this.radScheduler1.SchedulerElement.ViewElement as SchedulerDayViewGroupedByResourceElement;
               headerElement.ResourceHeaderHeight = 135;
     
               RadMessageBox.Show(new Form() { TopMost = true, StartPosition = FormStartPosition.CenterScreen },
                   "Information Saved.", "Aviso", MessageBoxButtons.OK, RadMessageIcon.Info, MessageBoxDefaultButton.Button1);
           }
  8. Dess
    Admin
    Dess avatar
    1900 posts

    Posted 15 Jun Link to this post

    Hello Alejandro, 

    Thank you for writing back. 

    I am glad the problem you were facing is now resolved. The provided code snippet will be useful for the community if encountering such a scenario.

    I hope this information helps. If you have any additional questions, please let me know. 

    Regards,
    Dess
    Progress Telerik
    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