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 )
 /**
  * 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;
     }
 }
Beispiel #2
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)
 {
     $item = $cell->getParent();
     switch ($itemType) {
         case TListItemType::Item:
         case TListItemType::AlternatingItem:
         case TListItemType::SelectedItem:
             if (($classPath = $this->getItemRenderer()) !== '') {
                 $control = Prado::createComponent($classPath);
                 if ($control instanceof IItemDataRenderer) {
                     $control->setItemIndex($item->getItemIndex());
                     $control->setItemType($item->getItemType());
                 }
                 $cell->getControls()->add($control);
             } else {
                 $control = $cell;
             }
             $control->attachEventHandler('OnDataBinding', array($this, 'dataBindColumn'));
             break;
         case TListItemType::EditItem:
             if (!$this->getReadOnly()) {
                 if (($classPath = $this->getEditItemRenderer()) !== '') {
                     $control = Prado::createComponent($classPath);
                     if ($control instanceof IItemDataRenderer) {
                         $control->setItemIndex($item->getItemIndex());
                         $control->setItemType($item->getItemType());
                     }
                     $cell->getControls()->add($control);
                     $cell->registerObject('EditControl', $control);
                 } else {
                     $control = new TTextBox();
                     $cell->getControls()->add($control);
                     $cell->registerObject('TextBox', $control);
                 }
             } else {
                 if (($classPath = $this->getItemRenderer()) !== '') {
                     $control = Prado::createComponent($classPath);
                     if ($control instanceof IItemDataRenderer) {
                         $control->setItemIndex($item->getItemIndex());
                         $control->setItemType($item->getItemType());
                     }
                     $cell->getControls()->add($control);
                 } else {
                     $control = $cell;
                 }
             }
             $control->attachEventHandler('OnDataBinding', array($this, 'dataBindColumn'));
             break;
         default:
             parent::initializeCell($cell, $columnIndex, $itemType);
             break;
     }
 }
Beispiel #3
0
 /**
  * Initializes the specified cell to its initial values.
  * This method overrides the parent implementation.
  * It creates a command button within the cell.
  * @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 ($itemType === TListItemType::Item || $itemType === TListItemType::AlternatingItem || $itemType === TListItemType::SelectedItem || $itemType === TListItemType::EditItem) {
         $buttonType = $this->getButtonType();
         if ($buttonType === TButtonColumnType::LinkButton) {
             $button = new TLinkButton();
         } else {
             if ($buttonType === TButtonColumnType::PushButton) {
                 $button = new TButton();
             } else {
                 $button = new TImageButton();
                 $button->setImageUrl($this->getImageUrl());
                 $button->setToolTip($this->getText());
             }
         }
         $button->setText($this->getText());
         $button->setCommandName($this->getCommandName());
         $button->setCausesValidation($this->getCausesValidation());
         $button->setValidationGroup($this->getValidationGroup());
         if ($this->getDataTextField() !== '' || $buttonType === TButtonColumnType::ImageButton && $this->getDataImageUrlField() !== '') {
             $button->attachEventHandler('OnDataBinding', array($this, 'dataBindColumn'));
         }
         $cell->getControls()->add($button);
         $cell->registerObject('Button', $button);
     } else {
         parent::initializeCell($cell, $columnIndex, $itemType);
     }
 }
Beispiel #4
0
 /**
  * Initializes the specified cell to its initial values.
  * This method overrides the parent implementation.
  * It creates a checkbox inside the cell.
  * If the column is read-only or if the item is not in edit mode,
  * the checkbox will be set disabled.
  * @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 ($itemType === TListItemType::Item || $itemType === TListItemType::AlternatingItem || $itemType === TListItemType::SelectedItem || $itemType === TListItemType::EditItem) {
         $checkBox = new TCheckBox();
         if ($this->getReadOnly() || $itemType !== TListItemType::EditItem) {
             $checkBox->setEnabled(false);
         }
         $cell->setHorizontalAlign('Center');
         $cell->getControls()->add($checkBox);
         $cell->registerObject('CheckBox', $checkBox);
         if ($this->getDataField() !== '') {
             $checkBox->attachEventHandler('OnDataBinding', array($this, 'dataBindColumn'));
         }
     } else {
         parent::initializeCell($cell, $columnIndex, $itemType);
     }
 }
Beispiel #5
0
 /**
  * Initializes the specified cell to its initial values.
  * This method overrides the parent implementation.
  * @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 ($itemType === TListItemType::Item || $itemType === TListItemType::AlternatingItem || $itemType === TListItemType::EditItem || $itemType === TListItemType::SelectedItem) {
         if ($this->getDataField() !== '') {
             $cell->attachEventHandler('OnDataBinding', array($this, 'dataBindColumn'));
         } else {
             $text = $this->getText();
             if ($this->getEncode()) {
                 $text = THttpUtility::htmlEncode($text);
             }
             $cell->setText($text);
         }
     } else {
         parent::initializeCell($cell, $columnIndex, $itemType);
     }
 }
Beispiel #6
0
 /**
  * Initializes the specified cell to its initial values.
  * This method overrides the parent implementation.
  * It creates an update and a cancel button for cell in edit mode.
  * Otherwise it creates an edit button.
  * @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 ($itemType === TListItemType::Item || $itemType === TListItemType::AlternatingItem || $itemType === TListItemType::SelectedItem) {
         $button = $this->createButton('Edit', $this->getEditText(), false, '');
         $cell->getControls()->add($button);
         $cell->registerObject('EditButton', $button);
     } else {
         if ($itemType === TListItemType::EditItem) {
             $controls = $cell->getControls();
             $button = $this->createButton('Update', $this->getUpdateText(), $this->getCausesValidation(), $this->getValidationGroup());
             $controls->add($button);
             $cell->registerObject('UpdateButton', $button);
             $controls->add(' ');
             $button = $this->createButton('Cancel', $this->getCancelText(), false, '');
             $controls->add($button);
             $cell->registerObject('CancelButton', $button);
         } else {
             parent::initializeCell($cell, $columnIndex, $itemType);
         }
     }
 }