/**
* Initializes the specified cell to its initial values.
* This method overrides the parent implementation.
* It creates a textbox for item in edit mode and the column is not read-only.
* Otherwise it displays a static text.
* The caption of the button and the static text are retrieved
* from the datasource.
* @param TTableCell the cell to be initialized.
* @param integer the index to the Columns property that the cell resides in.
* @param string the type of cell (Header,Footer,Item,AlternatingItem,EditItem,SelectedItem)
*/
public function initializeCell($cell, $columnIndex, $itemType)
{
if (!$this->_dataBound && $this->_listControl->getDataSource() !== null) {
$this->_listControl->setDataTextField($this->getListTextField());
$this->_listControl->setDataValueField($this->getListValueField());
$this->_listControl->setDataTextFormatString($this->getListTextFormatString());
$this->_listControl->dataBind();
$this->_dataBound = true;
}
switch ($itemType) {
case TListItemType::EditItem:
if (!$this->getReadOnly()) {
$listControl = clone $this->_listControl;
$cell->getControls()->add($listControl);
$cell->registerObject('DropDownList', $listControl);
$control = $listControl;
} else {
$control = $cell;
}
$control->attachEventHandler('OnDataBinding', array($this, 'dataBindColumn'));
break;
case TListItemType::Item:
case TListItemType::AlternatingItem:
case TListItemType::SelectedItem:
if ($this->getDataTextField() !== '' || $this->getDataValueField() !== '') {
$cell->attachEventHandler('OnDataBinding', array($this, 'dataBindColumn'));
}
break;
default:
parent::initializeCell($cell, $columnIndex, $itemType);
break;
}
}