TButtonColumn contains a user-defined command button, such as Add or Remove, that corresponds with each row in the column. The caption of the buttons in the column is determined by {@link setText Text} and {@link setDataTextField DataTextField} properties. If both are present, the latter takes precedence. The {@link setDataTextField DataTextField} property refers to the name of the field in datasource whose value will be used as the button caption. If {@link setDataTextFormatString DataTextFormatString} is not empty, the value will be formatted before rendering. The buttons in the column can be set to display as hyperlinks, push buttons or images by setting the {@link setButtonType ButtonType} property. The {@link setCommandName CommandName} will assign its value to all button's CommandName property. The datagrid will capture the command event where you can write event handlers based on different command names. The buttons' CausesValidation and ValidationGroup property values are determined by the column's corresponding properties. The buttons in the column can be accessed by one of the following two methods: $datagridItem->ButtonColumnID->Button $datagridItem->ButtonColumnID->Controls[0] The second method is possible because the button control created within the datagrid cell is the first child.
С версии: 3.0
Автор: Qiang Xue (qiang.xue@gmail.com)
Наследование: extends TDataGridColumn
Пример #1
0
 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);
     }
 }