This is a migrated thread and some comments may be shown as answers.

Appointment BackColor doesn't work

4 Answers 83 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Marco
Top achievements
Rank 1
Marco asked on 21 Feb 2011, 05:12 PM
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                   

4 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 21 Feb 2011, 05:37 PM
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!
0
Marco
Top achievements
Rank 1
answered on 21 Feb 2011, 06:02 PM
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
0
Marco
Top achievements
Rank 1
answered on 21 Feb 2011, 06:19 PM
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
0
Peter
Telerik team
answered on 22 Feb 2011, 03:58 PM

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!
Tags
Scheduler
Asked by
Marco
Top achievements
Rank 1
Answers by
Peter
Telerik team
Marco
Top achievements
Rank 1
Share this question
or