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

using resources with generic list bound appts

3 Answers 111 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Josh
Top achievements
Rank 1
Josh asked on 20 Sep 2007, 03:50 PM
Following the online demos for Binding to Generic Lists and Defining Resources as a guide, I have attempted to use resources to style my appointments. 

After running DataBind(), I can see that each Appointment has a resource but when the scheduler loads up, the styles are not taking effect. When I look at the page's html source, the appointment element has class="rsApt " (notice the space), not class="rsApt User".

The Defining Resources example source shows class="rsApt Alex" or Charlie or Bob.  The Binding to Generic List examples source shows the same thing that I am seeing.

Is this a bug, or is this functionality that is not available when binding to generic lists?  Any Ideas?

3 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 21 Sep 2007, 01:40 PM
Hello Josh,

The resource names are not automatically rendered as CSS classes. You should attach to the AppointmentCreated event and set them on the fly, as in the example:

protected void RadScheduler1_AppointmentCreated(object sender, AppointmentCreatedEventArgs e) 
    foreach (Resource resource in e.Appointment.Resources) 
    { 
        if (resource.Type == "User"
        { 
            e.Appointment.CssClass = resource.Text; 
        } 
    } 
 


Regards,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Ana
Top achievements
Rank 1
answered on 08 Apr 2013, 11:42 AM
As indicated in the title, I'm filling in the RadScheduler with a list (List <MyType>) and there's no way to fill in the resources.
I developed a parser to fill appointments but when i try to access to an appointment resource it crashes.
This is the binding code:
protected void Page_Init(object sender, EventArgs e)
    {
          //ORIGINAL BINDING MODE
         //List<CalendarAppointment> appointments = new List<CalendarAppointment>();
            //appointments.AddRange(business.GetCalendarAppointments(calendar.Id));
 
          List<Telerik.Web.UI.Appointment> appointments = new List<Telerik.Web.UI.Appointment>();
          appointments = ParsearAppointments(business.GetCalendarAppointments(calendar.Id));
         RadScheduler1.DataSource = appointments;
         RadScheduler1.DataBind();
    }
 
and there is the parser:
private List<Appointment> ParsearAppointments(List<CalendarAppointment> list)
{
    List<Appointment> appointments = new List<Appointment>();
    Telerik.Web.UI.Appointment a = new Telerik.Web.UI.Appointment();
    foreach (CalendarAppointment ap in list)
    {
        a.Subject=ap.Title;
        a.Description=ap.Description;
        a.Start=ap.StartDate;
        a.End=ap.EndDate;
        a.Attributes["Place"]=ap.Location;
        //a.Resources[0].Key=ap.CalendarId;---> it crashes here
        a.Attributes["Representant"]=ap.Representative;
       appointments.Add(a);
    }
 
    return appointments;
}

And the error code:

System.ArgumentOutOfRangeException
{"Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index"}


I would appreciate a way to fix this issue or another way to do this.
Ana
0
Boyan Dimitrov
Telerik team
answered on 11 Apr 2013, 08:53 AM
Hello,

It seems that the problem is caused by an empty resource collection for your appointment. In order to avoid that behavior I would suggest adding a resource to that item using the following expression:
//code behind
a.Resources.Add(new Resource(....));

Once you have a resource item added to the appointment resource collection, you will be able to access it by index.

Regards,
Boyan Dimitrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Scheduler
Asked by
Josh
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Ana
Top achievements
Rank 1
Boyan Dimitrov
Telerik team
Share this question
or