TCheckBox displays a check box on the page. You can specify the caption to display beside the check box by setting the {@link setText Text} property. The caption can appear either on the right or left of the check box, which is determined by the {@link setTextAlign TextAlign} property. To determine whether the TCheckBox component is checked, test the {@link getChecked Checked} property. The {@link onCheckedChanged OnCheckedChanged} event is raised when the {@link getChecked Checked} state of the TCheckBox component changes between posts to the server. You can provide an event handler for the {@link onCheckedChanged OnCheckedChanged} event to to programmatically control the actions performed when the state of the TCheckBox component changes between posts to the server. If {@link setAutoPostBack AutoPostBack} is set true, changing the check box state will cause postback action. And if {@link setCausesValidation CausesValidation} is true, validation will also be processed, which can be further restricted within a {@link setValidationGroup ValidationGroup}. Note, {@link setText Text} is rendered as is. Make sure it does not contain unwanted characters that may bring security vulnerabilities.
С версии: 3.0
Автор: Qiang Xue (qiang.xue@gmail.com)
Наследование: extends TWebControl, implements Prado\Web\UI\IPostBackDataHandler, implements Prado\Web\UI\IValidatable, implements Prado\IDataRenderer, implements Prado\Web\UI\ISurroundable
Пример #1
0
 protected function createBooleanControl($container, $column, $record)
 {
     $value = $this->getRecordPropertyValue($column, $record);
     $control = new TCheckBox();
     $control->setChecked(TPropertyValue::ensureBoolean($value));
     $control->setCssClass('boolean-checkbox');
     $this->setDefaultProperty($container, $control, $column, $record);
     return $control;
 }
Пример #2
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);
     }
 }
Пример #3
0
 /**
  * @return string the value attribute to be rendered
  */
 protected function getValueAttribute()
 {
     if (($value = parent::getValueAttribute()) === '') {
         return $this->getUniqueID();
     } else {
         return $value;
     }
 }
Пример #4
0
 /**
  * Override client implementation to avoid emitting the javascript
  *
  * @param THtmlWriter the writer for the rendering purpose
  * @param string checkbox id
  * @param string onclick js
  */
 protected function renderInputTag($writer, $clientID, $onclick)
 {
     TCheckBox::renderInputTag($writer, $clientID, $onclick);
 }
Пример #5
0
 /**
  * @return string checkbox label ID;
  */
 protected function getDefaultLabelID()
 {
     if ($attributes = $this->getViewState('LabelAttributes', null)) {
         return TCheckBox::getLabelAttributes()->itemAt('id');
     } else {
         return $this->getClientID() . '_label';
     }
 }