Appointment BackColor doesn't work

5 posts, 0 answers
  1. Marco
    Marco avatar
    3 posts
    Member since:
    Feb 2011

    Posted 21 Feb 2011 Link to this post

    Hello Telerik family.

    I am tring to use scheduler component in a mvc project.
    here there is my view :

    <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
    <%@ Register Assembly="RadSchedulerDemo" Namespace="RadSchedulerDemo.Helpers" TagPrefix="cc1" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <script runat="server">
        //needed to run RadScheduler without <form> tag
        public override void VerifyRenderingInServerForm(Control control) {
            //base.VerifyRenderingInServerForm(control);
        }
    </script>
    <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
        Index
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
        <telerik:RadScriptManager runat="server" ID="RadScriptManager1">
        </telerik:RadScriptManager>
     
        <!-- to allow for user authentication, a custom control needed to be created to handle
                the ASPXAUTH cookie during the GetResources call.  see
                and relevant code in Helpers\MyScheduler.cs
        -->
        <cc1:MyScheduler ID="MyScheduler1" runat="server" SelectedView="WeekView" StartInsertingInAdvancedForm="true"  AppointmentStyleMode="Default" 
            StartEditingInAdvancedForm="true">
            <AdvancedForm Enabled="true" Modal="true" />
            <WebServiceSettings Path="~/SchedulerService" ResourcePopulationMode="ServerSide" UseHttpGet="false" />
        </cc1:MyScheduler>
    </asp:Content>

    And here there is the override of teh GetAppointments from SchedulerProviderBase in my implementation of the WebServiceAppointmentController



    public override IEnumerable<Appointment> GetAppointments(RadScheduler owner)
            {
                List<Appointment> list = new List<Appointment>();
                AppointmentDS.SchedarioDataTable dt = null;
                DateTime star;
                DateTime end;
                Dictionary<DateTime, List<Appointment>> dic = new Dictionary<DateTime, List<Appointment>>();
     
                int ora = 9;
                int cont = 0;
     
                try
                {
                    dt = dal.getSchedarioDT(DateTime.Today, DateTime.Today.AddDays(-7), DateTime.Today.AddDays(7));
                    foreach (AppointmentDS.SchedarioRow row in dt)
                    {
     
                        Appointment item = owner.CreateAppointment();
     
                        item.ID = row.STR_Id;
                        if (row.IsTIS_NomeNull())
                            item.Subject = "";
                        else
                            item.Subject = row.TIS_Nome;
     
                        star = new DateTime(row.PST_DataScadenza.Year, row.PST_DataScadenza.Month, row.PST_DataScadenza.Day,0,0,0);
                        end = new DateTime(row.PST_DataScadenza.Year, row.PST_DataScadenza.Month, row.PST_DataScadenza.Day, 0, 0, 0);
                         
                        item.Start = star.ToUniversalTime();
                        item.End = end.ToUniversalTime();
     
                        item.BackColor = System.Drawing.Color.Yellow;
                        item.CssClass = "testtest";
     
                        list.Add(item);
     
                    }
     
                   

                     
                }
                catch (Exception ex)
                {
                     
                    throw;
                }
                return list;
     
            }
    How you can see I use the item.BackColor = System.Drawing.Color.Yellow;
    But it don't take effect in the View.

    Samebody can help me please?

    Thanks a lot                   

  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 21 Feb 2011 Link to this post

    Hello Marco,

    With Web Service binding, the BackColor property should be set on the client in OnClientAppointmentDataBound:

    function OnClientAppointmentDataBound(sender, args)
         
             args.get_appointment().set_backColor("yellow");        
         }


    Kind regards,
    Peter
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. Marco
    Marco avatar
    3 posts
    Member since:
    Feb 2011

    Posted 21 Feb 2011 Link to this post

    Hello Peater

    thank for your fast reply, I tried it out and it works perfectly.

    But It change all the appointments color.

    I would like to change the color dinamicaly using a data row property in my GetAppointments override:
     Like this
    if (row.isValid)
        item.BackColor = System.Drawing.Color.Green;
    else
        item.BackColor = System.Drawing.Color.Red;

    May I replicate the same in the client?

    thanks a lot

    Marco
  4. Marco
    Marco avatar
    3 posts
    Member since:
    Feb 2011

    Posted 21 Feb 2011 Link to this post

    Hello Peater

    i found a soluction to my problem, your first post opened my mind.

    I solved in this way:

    in my GetAppointmentsoverride I add an attribute to the Appointment Object  like this:
    item.Attributes.Add("isValidate""no");
    
    
    in the Client function I added : 
    function OnClientAppointmentDataBound(sender, args)
          {
              var obj = args.get_data();
              obj = obj["Attributes"];
              if(obj=="no"){
                  args.get_appointment().set_backColor("yellow");
                  }
                  else{
                     args.get_appointment().set_backColor("red");
                  }
          }
    I hope that can be useful. Thanks a lot for your atention Marco
  5. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 22 Feb 2011 Link to this post


    Yes, that's indeed useful. Thanks for expanding on this case and for sharing your findings in the forum.


    All the best,
    Peter
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Back to Top