search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Custom Object ArrayList Binding

Asked by Charlie
9 years ago.

I'm building on the Pro Demo 5.8 until I can get it all working. If it all goes well then I'll probably purchase.

I've got an ArrayList of objects (TimeEntries) that I'm binding to the Month view.

My TimeEntry object has some fields and some other objects in it.

Two of the objects are Task and User.

I'd like to reference some attributes of the Task for the description and use a color attribute that is part of the User when building the month view.

I see in the demo how to use the cell prerender to set the colors of the text, etc but I'm having trouble getting to those attributes in my TimeEntry ArrayList.

Any help would really be appreciated.

Comment posted by Dan Letecky
9 years ago.

There is a special property to map custom event attributes - DataTagFields.

Let's say your TimeEntry class looks like this:

public class TimeEntry {
  public DateTime Start {get; set;}
  public DateTime End {get; set; }
  public string Text {get; set;}
  public string Id {get; set;}
  public string Color {get; set;}
  public string Details {get; set;}
}

You will want to map Start, End, Text, and Id using DataStartField, DataEndField, DataTextField, and DataValueField.

Any other properties can be mapped using DataTagFields:

DataTagFields="Color, Details"

These fields can be accessed using e.Tag["Color"] and e.Tag["Details"] in the BeforeEventRender event handler.

See also Custom event rendering topic in the Calendar documentation (it works the same way for the Month control).

Comment posted by Charlie
9 years ago.

sweet. I'll give it a go this morning. thanks

Comment posted by Charlie
9 years ago.

My TimeEntry looks like this

public class TimeEntry {
public Task task
public DateTime Start {get; set;}
public DateTime End {get; set; }
public string Text {get; set;}
public string Id {get; set;}
public string Color {get; set;}
public string Details {get; set;}
}

and my Task looks like

public class Task{
public string description(get;set}

}

I'd like to get the description of the Task without having to add a pointer attribute in the TimeEntry

Comment posted by Charlie
9 years ago.

by pointer attribute I mean putting an attribute on TimeEntry like this

public TimeEntryDescription
{
get
{
return task.Description
}
}

Rather be able to dig to the attribute I'm needing. Thoughts?

Comment posted by Dan Letecky
9 years ago.

It only works one level deep. You are not able to reach properties of properties at this moment.

If you need to reach properties of the task property, you would need to serialize them into a signle field:

public TimeEntryTaskProperties
{
  get
  {
 return String.Join(",", new string[] {task.Description, task.Whatever});
 }
}

And access them again using String.Split(",").

I'm not sure if this would be more convenient than mapping individual child properties though.

This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.