Overview

Packages

  • bootstrap
    • behaviors
    • components
    • form
    • gii
    • helpers
    • widgets

Classes

  • TbActiveForm
  • TbAffix
  • TbAlert
  • TbBreadcrumb
  • TbButtonColumn
  • TbCollapse
  • TbDataColumn
  • TbDetailView
  • TbGridView
  • TbHeroUnit
  • TbListView
  • TbModal
  • TbNav
  • TbNavbar
  • TbPager
  • TbScrollspy
  • TbTabs
  • TbThumbnails
  • TbTypeAhead
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * TbDataColumn class file.
  4:  * @author Antonio Ramirez <ramirez.cobos@gmail.com>
  5:  * @author Christoffer Niska <ChristofferNiska@gmail.com>
  6:  * @copyright Copyright &copy; Christoffer Niska 2013-
  7:  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  8:  * @package bootstrap.widgets
  9:  */
 10: 
 11: Yii::import('bootstrap.helpers.TbHtml');
 12: Yii::import('zii.widgets.grid.CDataColumn');
 13: 
 14: /**
 15:  * Bootstrap grid data column.
 16:  */
 17: class TbDataColumn extends CDataColumn
 18: {
 19:     /**
 20:      * @var array HTML options for filter input
 21:      * @link {TbDataColumn::renderFilterCellContent()}
 22:      */
 23:     public $filterInputOptions;
 24: 
 25:     /**
 26:      * Renders the header cell content.
 27:      * This method will render a link that can trigger the sorting if the column is sortable.
 28:      */
 29:     protected function renderHeaderCellContent()
 30:     {
 31:         if ($this->grid->enableSorting && $this->sortable && $this->name !== null) {
 32:             $sort = $this->grid->dataProvider->getSort();
 33:             $label = isset($this->header) ? $this->header : $sort->resolveLabel($this->name);
 34: 
 35:             if ($sort->resolveAttribute($this->name) !== false) {
 36:                 $label .= '<span class="caret"></span>';
 37:             }
 38: 
 39:             echo $sort->link($this->name, $label, array('class' => 'sort-link'));
 40:         } else {
 41:             if ($this->name !== null && $this->header === null) {
 42:                 if ($this->grid->dataProvider instanceof CActiveDataProvider) {
 43:                     echo CHtml::encode($this->grid->dataProvider->model->getAttributeLabel($this->name));
 44:                 } else {
 45:                     echo CHtml::encode($this->name);
 46:                 }
 47:             } else {
 48:                 parent::renderHeaderCellContent();
 49:             }
 50:         }
 51:     }
 52: 
 53:     /**
 54:      * Renders the filter cell.
 55:      */
 56:     public function renderFilterCell()
 57:     {
 58:         echo CHtml::openTag('td', $this->filterHtmlOptions);
 59:         echo '<div class="filter-container">';
 60:         $this->renderFilterCellContent();
 61:         echo '</div>';
 62:         echo CHtml::closeTag('td');
 63:     }
 64: 
 65:     /**
 66:      * Renders the filter cell content. Here we can provide HTML options for actual filter input
 67:      */
 68:     protected function renderFilterCellContent()
 69:     {
 70:         if (is_string($this->filter)) {
 71:             echo $this->filter;
 72:         } else {
 73:             if ($this->filter !== false && $this->grid->filter !== null && $this->name !== null && strpos(
 74:                     $this->name,
 75:                     '.'
 76:                 ) === false
 77:             ) {
 78:                 if ($this->filterInputOptions) {
 79:                     $filterInputOptions = $this->filterInputOptions;
 80:                     if (empty($filterInputOptions['id'])) {
 81:                         $filterInputOptions['id'] = false;
 82:                     }
 83:                 } else {
 84:                     $filterInputOptions = array();
 85:                 }
 86:                 if (is_array($this->filter)) {
 87:                     $filterInputOptions['prompt'] = '';
 88:                     echo CHtml::activeDropDownList(
 89:                         $this->grid->filter,
 90:                         $this->name,
 91:                         $this->filter,
 92:                         $filterInputOptions
 93:                     );
 94:                 } else {
 95:                     if ($this->filter === null) {
 96:                         echo CHtml::activeTextField($this->grid->filter, $this->name, $filterInputOptions);
 97:                     }
 98:                 }
 99:             } else {
100:                 parent::renderFilterCellContent();
101:             }
102:         }
103:     }
104: }
105: 
Yiistrap API documentation generated by ApiGen 2.8.0