Hello Art,
Thank you for writing.
You could iterate the RadScheduler.
Resources collection and select the resource which has an
Id equal to the searched employee number.
I have prepared a small example in which I populate sample data and later in the handler of a button Click event add a new appointment to an employee according to its id. Please see my implementation below:
public
partial
class
Form1 : Form
{
Appointment appointment;
Random rand;
public
Form1()
{
InitializeComponent();
DateTime baseDate = DateTime.Today;
DateTime[] start =
new
DateTime[] { baseDate.AddHours(14.0), baseDate.AddDays(1.0).AddHours(9.0), baseDate.AddDays(2.0).AddHours(13.0),
baseDate.AddDays(1.0).AddHours(17.0), baseDate.AddDays(1.0).AddHours(5.0) };
DateTime[] end =
new
DateTime[] { baseDate.AddHours(16.0), baseDate.AddDays(1.0).AddHours(15.0), baseDate.AddDays(2.0).AddHours(17.0),
baseDate.AddDays(1.0).AddHours(21.0), baseDate.AddDays(1.0).AddHours(8.0)};
string
[] summaries =
new
string
[] {
"Mr. Brown"
,
"Mr. White"
,
"Mrs. Green"
,
"Ms. Black"
,
"Mrs. Grey"
};
rand =
new
Random();
Color[] colors =
new
Color[]
{
Color.LightBlue, Color.LightGreen, Color.LightYellow,
Color.Red, Color.Orange, Color.Pink, Color.Purple, Color.Peru, Color.PowderBlue
};
string
[] names =
new
string
[]
{
"Alan Smith"
,
"Anne Dodsworth"
,
"Boyan Mastoni"
,
"Richard Duncan"
,
"Maria Shnaider"
};
for
(
int
i = 0; i < names.Length; i++)
{
Resource resource =
new
Resource();
resource.Id =
new
EventId(rand.Next(10000, 20000));
resource.Name = names[i];
resource.Color = colors[i];
this
.radScheduler1.Resources.Add(resource);
Console.WriteLine(
"Name: "
+ resource.Name +
" No.: "
+ resource.Id);
}
this
.radScheduler1.GetDayView().ResourcesPerView = 5;
this
.radScheduler1.GroupType = GroupType.Resource;
SchedulerDayViewGroupedByResourceElement headerElement =
this
.radScheduler1.SchedulerElement.ViewElement
as
SchedulerDayViewGroupedByResourceElement;
headerElement.ResourceHeaderHeight = 80;
for
(
int
i = 0; i < summaries.Length; i++)
{
appointment =
new
Appointment(start[i], end[i], summaries[i]);
appointment.ResourceId =
this
.radScheduler1.Resources[i].Id;
this
.radScheduler1.Appointments.Add(appointment);
}
}
private
void
radButton1_Click(
object
sender, EventArgs e)
{
int
employeeId;
bool
isInt =
int
.TryParse(
this
.radTextBox1.Text,
out
employeeId);
if
(isInt)
{
IResource resource =
this
.radScheduler1.Resources.Where(r => (
int
)r.Id.KeyValue == employeeId).FirstOrDefault();
if
(resource !=
null
)
{
appointment =
new
Appointment();
appointment.ResourceId = resource.Id;
this
.radScheduler1.Appointments.Add(appointment);
}
}
}
}
I am also sending you a
.gif file showing how the scheduler behaves on my end.
I hope this information helps. Should you have further questions please do not hesitate to write back.
Regards,
Hristo
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.