protected function createButton($commandName, $text, $causesValidation, $validationGroup) { if ($this->getButtonType() === TButtonColumnType::LinkButton) { $button = new TActiveLinkButton(); } else { if ($this->getButtonType() === TButtonColumnType::PushButton) { $button = new TActiveButton(); } else { $button = new TActiveImageButton(); $button->setToolTip($text); 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; }
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 TActiveLinkButton(); } else { if ($buttonType === TButtonColumnType::PushButton) { $button = new TActiveButton(); } else { $button = new TActiveImageButton(); $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); } }
protected function initializeHeaderCell($cell, $columnIndex) { $text = $this->getHeaderText(); if (($classPath = $this->getHeaderRenderer()) !== '') { $control = Prado::createComponent($classPath); if ($control instanceof \Prado\IDataRenderer) { if ($control instanceof IItemDataRenderer) { $item = $cell->getParent(); $control->setItemIndex($item->getItemIndex()); $control->setItemType($item->getItemType()); } $control->setData($text); } $cell->getControls()->add($control); } else { if ($this->getAllowSorting()) { $sortExpression = $this->getSortExpression(); if (($url = $this->getHeaderImageUrl()) !== '') { $button = new TActiveImageButton(); $button->setImageUrl($url); $button->setCommandName(TDataGrid::CMD_SORT); $button->setCommandParameter($sortExpression); if ($text !== '') { $button->setAlternateText($text); $button->setToolTip($text); } $button->setCausesValidation(false); $cell->getControls()->add($button); } else { if ($text !== '') { $button = new TActiveLinkButton(); $button->setText($text); $button->setCommandName(TDataGrid::CMD_SORT); $button->setCommandParameter($sortExpression); $button->setCausesValidation(false); $cell->getControls()->add($button); } else { $cell->setText(' '); } } } else { if (($url = $this->getHeaderImageUrl()) !== '') { $image = new TActiveImage(); $image->setImageUrl($url); if ($text !== '') { $image->setAlternateText($text); $image->setToolTip($text); } $cell->getControls()->add($image); } else { if ($text !== '') { $cell->setText($text); } else { $cell->setText(' '); } } } } }
/** * Creates a pager button. * Override parent implementation to create, depending on the button type, a TActiveLinkButton, * a TActiveButton or a TActiveImageButton may be created. * * @param string button type, either LinkButton or PushButton * @param boolean whether the button should be enabled * @param string caption of the button * @param string CommandName corresponding to the OnCommand event of the button * @param string CommandParameter corresponding to the OnCommand event of the button * @return mixed the button instance */ protected function createPagerButton($buttonType, $enabled, $text, $commandName, $commandParameter) { if ($buttonType === TPagerButtonType::LinkButton) { if ($enabled) { $button = new TActiveLinkButton(); } else { $button = new TLabel(); $button->setText($text); $button->setCssClass($this->getButtonCssClass()); return $button; } } else { if ($buttonType === TPagerButtonType::ImageButton) { $button = new TActiveImageButton(); $button->setImageUrl($this->getPageImageUrl($text, $commandName)); if ($enabled) { $button->Visible = true; } else { $button->Visible = false; } } else { $button = new TActiveButton(); if (!$enabled) { $button->setEnabled(false); } } } if ($buttonType === TPagerButtonType::ImageButton) { $button->ImageUrl = $text; } $button->setText($text); $button->setCommandName($commandName); $button->setCommandParameter($commandParameter); $button->setCausesValidation(false); $button->setCssClass($this->getButtonCssClass()); $button->attachEventHandler('OnCallback', array($this, 'handleCallback')); $button->getAdapter()->getBaseActiveControl()->setClientSide($this->getClientSide()); return $button; }