Prado\Web\UI\WebControls\TDataGridColumn::initializeCell PHP Method

initializeCell() public method

The default implementation sets the content of header and footer cells. If sorting is enabled by the grid and sort expression is specified in the column, the header cell will show a link/image button. Otherwise, the header/footer cell will only show static text/image. This method can be overriden to provide customized intialization to column cells.
public initializeCell ( $cell, $columnIndex, $itemType )
    public function initializeCell($cell, $columnIndex, $itemType)
    {
        if ($itemType === TListItemType::Header) {
            $this->initializeHeaderCell($cell, $columnIndex);
        } else {
            if ($itemType === TListItemType::Footer) {
                $this->initializeFooterCell($cell, $columnIndex);
            }
        }
    }

Usage Example

Example #1
0
 /**
  * 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;
     }
 }
All Usage Examples Of Prado\Web\UI\WebControls\TDataGridColumn::initializeCell