/** * 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); } }
/** * Creates a button and initializes its properties. * The button type is determined by {@link getButtonType ButtonType}. * @param string command name associated with the button * @param string button caption * @param boolean whether the button should cause validation * @param string the validation group that the button belongs to * @return mixed the newly created button. */ protected function createButton($commandName, $text, $causesValidation, $validationGroup) { if ($this->getButtonType() === TButtonColumnType::LinkButton) { $button = new TLinkButton(); } else { if ($this->getButtonType() === TButtonColumnType::PushButton) { $button = new TButton(); } else { $button = new TImageButton(); if (strcasecmp($commandName, 'Update') === 0) { $url = $this->getUpdateImageUrl(); } else { if (strcasecmp($commandName, 'Cancel') === 0) { $url = $this->getCancelImageUrl(); } else { $url = $this->getEditImageUrl(); } } $button->setImageUrl($url); } } $button->setText($text); $button->setCommandName($commandName); $button->setCausesValidation($causesValidation); $button->setValidationGroup($validationGroup); return $button; }