コード例 #1
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);
         }
     }
 }
コード例 #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)
 {
     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;
     }
 }
コード例 #3
0
ファイル: TBoundColumn.php プロジェクト: tejdeeps/tejcs.com
 /**
  * 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 = Prado::createComponent('System.Web.UI.WebControls.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;
     }
 }
コード例 #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);
     }
 }
コード例 #5
0
ファイル: TButtonColumn.php プロジェクト: tejdeeps/tejcs.com
 /**
  * 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);
     }
 }
コード例 #6
0
ファイル: TLiteralColumn.php プロジェクト: tejdeeps/tejcs.com
 /**
  * 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);
     }
 }
コード例 #7
0
 /**
  * Initializes the specified cell to its initial values.
  * This method overrides the parent implementation.
  * It creates a hyperlink 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) {
         $link = new THyperLink();
         if (($url = $this->getImageUrl()) !== '') {
             $link->setImageUrl($url);
             if (($width = $this->getImageWidth()) !== '') {
                 $link->setImageWidth($width);
             }
             if (($height = $this->getImageHeight()) !== '') {
                 $link->setImageHeight($height);
             }
         }
         $link->setText($this->getText());
         $link->setNavigateUrl($this->getNavigateUrl());
         $link->setTarget($this->getTarget());
         if ($this->getDataTextField() !== '' || $this->getDataNavigateUrlField() !== '') {
             $link->attachEventHandler('OnDataBinding', array($this, 'dataBindColumn'));
         }
         $cell->getControls()->add($link);
         $cell->registerObject('HyperLink', $link);
     } else {
         parent::initializeCell($cell, $columnIndex, $itemType);
     }
 }
コード例 #8
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)
 {
     parent::initializeCell($cell, $columnIndex, $itemType);
     if ($itemType === TDataGridItem::TYPE_ITEM || $itemType === TDataGridItem::TYPE_ALTERNATING_ITEM || $itemType === TDataGridItem::TYPE_SELECTED_ITEM || $itemType === TDataGridItem::TYPE_EDIT_ITEM && $this->isReadOnly()) {
         $text = $cell->getContainer()->Data[$this->getDataField()];
         $cell->setText($this->formatDataValue($text));
     } else {
         if ($itemType === TDataGridItem::TYPE_EDIT_ITEM) {
             $textbox = new TTextBox();
             $cell->addChild($textbox);
             $cell->addBody($textbox);
             $text = $cell->getContainer()->Data[$this->getDataField()];
             $textbox->setText($text);
         }
     }
 }
コード例 #9
0
 /**
  * Initializes the specified cell to its initial values.
  * This method overrides the parent implementation.
  * It initializes the cell based on different templates 
  * (ItemTemplate, EditItemTemplate, HeaderTemplate, FooterTemplate).
  * @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 === TDataGridItem::TYPE_EDIT_ITEM) {
         parent::initializeCell($cell, $columnIndex, $itemType);
         $template = $this->getEditItemTemplate();
         if (strlen($template)) {
             $cell->instantiateTemplate($template);
         } else {
             $cell->addBody(' ');
         }
     } else {
         if ($itemType === TDataGridItem::TYPE_HEADER) {
             $headerTemplate = $this->getHeaderTemplate();
             if (strlen($headerTemplate)) {
                 $cell->instantiateTemplate($headerTemplate);
             } else {
                 parent::initializeCell($cell, $columnIndex, $itemType);
             }
         } else {
             if ($itemType === TDataGridItem::TYPE_FOOTER) {
                 $footerTemplate = $this->getFooterTemplate();
                 if (strlen($footerTemplate)) {
                     $cell->instantiateTemplate($footerTemplate);
                 } else {
                     parent::initializeCell($cell, $columnIndex, $itemType);
                 }
             } else {
                 parent::initializeCell($cell, $columnIndex, $itemType);
                 $template = $this->getItemTemplate();
                 if (strlen($template)) {
                     $cell->instantiateTemplate($template);
                 } else {
                     $cell->addBody(' ');
                 }
             }
         }
     }
 }
コード例 #10
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)
 {
     parent::initializeCell($cell, $columnIndex, $itemType);
     if ($itemType === TDataGridItem::TYPE_ITEM || $itemType === TDataGridItem::TYPE_ALTERNATING_ITEM || $itemType === TDataGridItem::TYPE_SELECTED_ITEM || $itemType === TDataGridItem::TYPE_EDIT_ITEM) {
         $buttonType = $this->getButtonType() === 'LinkButton' ? 'TLinkButton' : 'TButton';
         $button = $cell->createComponent($buttonType);
         $textField = $this->getDataTextField();
         if (strlen($textField)) {
             $text = $cell->getContainer()->Data[$textField];
             $text = $this->formatDataTextValue($text);
         } else {
             $text = $this->getText();
         }
         $button->setText($text);
         $button->setCommandName($this->getCommandName());
         $button->setCausesValidation(false);
         $cell->addBody($button);
     }
 }
コード例 #11
0
 /**
  * Initializes the specified cell to its initial values.
  * This method overrides the parent implementation.
  * It creates a hyperlink 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)
 {
     parent::initializeCell($cell, $columnIndex, $itemType);
     if ($itemType === TDataGridItem::TYPE_ITEM || $itemType === TDataGridItem::TYPE_ALTERNATING_ITEM || $itemType === TDataGridItem::TYPE_SELECTED_ITEM || $itemType === TDataGridItem::TYPE_EDIT_ITEM) {
         $textField = $this->getDataTextField();
         if (strlen($textField)) {
             $text = $cell->getContainer()->Data[$textField];
             $text = $this->formatDataTextValue($text);
         } else {
             $text = $this->getText();
         }
         $urlField = $this->getDataNavigateUrlField();
         if (strlen($urlField)) {
             $url = $cell->getContainer()->Data[$urlField];
             $url = $this->formatDataNavigateUrlValue($url);
         } else {
             $url = $this->getNavigateUrl();
         }
         $link = $cell->createComponent('THyperLink');
         $link->setEncodeText($this->isEncodeText());
         $link->setText($text);
         $link->setNavigateUrl($url);
         $link->setTarget($this->getTarget());
         $cell->addBody($link);
     }
 }
コード例 #12
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)
 {
     parent::initializeCell($cell, $columnIndex, $itemType);
     $buttonType = $this->getButtonType() == 'LinkButton' ? 'TLinkButton' : 'TButton';
     if ($itemType === TDataGridItem::TYPE_ITEM || $itemType === TDataGridItem::TYPE_ALTERNATING_ITEM || $itemType === TDataGridItem::TYPE_SELECTED_ITEM) {
         $editText = $this->getEditText();
         if (strlen($editText)) {
             $button = $cell->createComponent($buttonType);
             $button->setText($editText);
             $button->setCommandName(TDataGrid::CMD_EDIT);
             $cell->addBody($button);
         }
     } else {
         if ($itemType === TDataGridItem::TYPE_EDIT_ITEM) {
             $updateText = $this->getUpdateText();
             if (strlen($updateText)) {
                 $button = $cell->createComponent($buttonType);
                 $button->setText($updateText);
                 $button->setCommandName(TDataGrid::CMD_UPDATE);
                 $cell->addBody($button);
             }
             $cancelText = $this->getCancelText();
             if (strlen($cancelText)) {
                 $cell->addBody(' ');
                 $button = $cell->createComponent($buttonType);
                 $button->setText($cancelText);
                 $button->setCommandName(TDataGrid::CMD_CANCEL);
                 $button->setCausesValidation(false);
                 $cell->addBody($button);
             }
         }
     }
 }