Edit this page

Scheduler Cell Containers

The cell containers in RadScheduler are the elements which contain cells and appointments. The cells and the appointments are dynamic elements which get recycled and updated under various conditions. The cell containers are responsible for handling this. All cell containers inherit from the abstract SchedulerCellContainer class. Elements that implement this type are: DayViewAllDayHeader, DayViewAppointmentsTable, DayViewHeader, MonthViewAreaElement, MonthViewHeader, MonthViewVerticalHeader, TimelineAppointmentsPresenter, TimelineHeader.

Initializing The Elements

The InitializeCells and InitializeAppointments methods are used to refresh the cell elements and appointment elements respectively. Both methods first remove the existing elements and add them to a cache so they can be reused later. After that new elements are either created or pulled out from the cache. The methods are called when the containers are being constructed and when a change that requires a refresh of the elements occurs (e.g. if you change the DayCount in day view). The AppointmentsRefreshing and CellsRefreshing events are fired by these methods before the refresh is performed. These event allow you to cancel the refresh. The AppointmentRefreshed and CellsRefreshed events are fired after the refresh is performed and allow you to do some custom operations over the newly created elements.

Initialize Elements

DayViewAppointmentsTable table = ((SchedulerDayViewElement)this.radScheduler1.ViewElement).DataAreaElement.Table;
table.CellsRefreshed +=table_CellsRefreshed;
table.AppointmentsRefreshed +=table_AppointmentsRefreshed;
table.InitializeCells();
table.InitializeAppointments();
//or use the following method which calls both of the above methods
table.InitializeChildren();

Dim table As DayViewAppointmentsTable = DirectCast(Me.radScheduler1.ViewElement, SchedulerDayViewElement).DataAreaElement.Table
AddHandler table.CellsRefreshed, AddressOf table_CellsRefreshed
AddHandler table.AppointmentsRefreshed, AddressOf table_AppointmentsRefreshed
table.InitializeCells()
table.InitializeAppointments()
'or use the following method which calls both of the above methods
table.InitializeChildren()

Handle Events

void table_AppointmentsRefreshed(object sender, EventArgs e)
{
    RadMessageBox.Show("Appointments were refreshed");
}
void table_CellsRefreshed(object sender, EventArgs e)
{
    RadMessageBox.Show("Cells were refreshed");
}

Private Sub table_AppointmentsRefreshed(sender As Object, e As EventArgs)
    RadMessageBox.Show("Appointments were refreshed")
End Sub
Private Sub table_CellsRefreshed(sender As Object, e As EventArgs)
    RadMessageBox.Show("Cells were refreshed")
End Sub

Updating The Elements

The UpdateCells and UpdateAppointments are called to synchronize the existing elements with the information from the active view (e.g. when the start date of the view changes, the cells’ dates are synchronized). Unlike the Initialize methods, these methods leave the elements as they are and just update their properties. The Initialize methods call these methods when the new elements are created to update their properties. These methods cause the CellFormatting and AppointmentFormatting events respectively.

Update Elements

DayViewAppointmentsTable table = ((SchedulerDayViewElement)this.radScheduler1.ViewElement).DataAreaElement.Table;
table.UpdateCells();
table.UpdateAppointments();

Dim table As DayViewAppointmentsTable = DirectCast(Me.radScheduler1.ViewElement, SchedulerDayViewElement).DataAreaElement.Table
table.UpdateCells()
table.UpdateAppointments()

Getting The Existing Elements

You can access the cell element and the appointment elements from a SchedulerCellContainer by using the CellElements and the AppointmentElements collections.

Access Elements

DayViewAppointmentsTable table = ((SchedulerDayViewElement)this.radScheduler1.ViewElement).DataAreaElement.Table;
foreach (SchedulerCellElement cellElement in table.CellElements)
{
    cellElement.BackColor = Color.Red;
}
foreach (AppointmentElement appElement in table.AppointmentElements)
{
    appElement.BackColor = Color.Green;
}

Dim table As DayViewAppointmentsTable = DirectCast(Me.radScheduler1.ViewElement, SchedulerDayViewElement).DataAreaElement.Table
For Each cellElement As SchedulerCellElement In table.CellElements
    cellElement.BackColor = Color.Red
Next
For Each appElement As AppointmentElement In table.AppointmentElements
    appElement.BackColor = Color.Green
Next

Accessing The Containers From The ViewElement

The SchedulerViewElement base type provides means for accessing the containers in the current view. Using the GetCellContainers method you can get all the containers in a list and perform for example an update operation over all of them:

Update Elements In The Container

foreach (SchedulerCellContainer cellContainer in this.radScheduler1.ViewElement.GetCellContainers())
{
    cellContainer.UpdateCells();
}

For Each cellContainer As SchedulerCellContainer In Me.radScheduler1.ViewElement.GetCellContainers()
    cellContainer.UpdateCells()
Next

For your convenience, there are the InitializeCells, UpdateCells, InitializeAppointmentElements, UpdateAppointmentElements methods of the view element which you can use to perform the same operation over all of the child SchedulerCellContainers:

Update Elements From The View Element

this.radScheduler1.ViewElement.UpdateCells();
this.radScheduler1.ViewElement.UpdateAppointmentElements();

Me.radScheduler1.ViewElement.UpdateCells()
Me.radScheduler1.ViewElement.UpdateAppointmentElements()

Additionally, there are the GetCellEments and the GetAppointmentElements methods which return a list of all cell or appointment elements from all containers in the view.

Get Elements

foreach (SchedulerCellElement cellElement in this.radScheduler1.ViewElement.GetCellElements())
{
    cellElement.BackColor = Color.Red;
}
foreach (AppointmentElement appElement in this.radScheduler1.ViewElement.GetAppointmentElements())
{
    appElement.BackColor = Color.Green;
}

For Each cellElement As SchedulerCellElement In Me.radScheduler1.ViewElement.GetCellElements()
    cellElement.BackColor = Color.Red
Next
For Each appElement As AppointmentElement In Me.radScheduler1.ViewElement.GetAppointmentElements()
    appElement.BackColor = Color.Green
Next

See Also