10 Yii::import(
'zii.widgets.grid.CGridView');
11 Yii::import(
'booster.widgets.TbDataColumn');
43 public $pager = array(
'class' =>
'booster.widgets.TbPager');
70 $classes = array(
'table');
71 if (isset($this->type)) {
72 if (is_string($this->type)) {
73 $this->type = explode(
' ', $this->type);
76 if (!empty($this->type)) {
77 $validTypes = array(self::TYPE_STRIPED, self::TYPE_BORDERED, self::TYPE_CONDENSED, self::TYPE_HOVER);
79 foreach ($this->type as
$type) {
80 if (in_array($type, $validTypes)) {
81 $classes[] =
'table-' .
$type;
87 if (!empty($classes)) {
88 $classes = implode(
' ', $classes);
89 if (isset($this->itemsCssClass)) {
90 $this->itemsCssClass .=
' ' . $classes;
92 $this->itemsCssClass = $classes;
97 $popover = $booster->popoverSelector;
98 $tooltip = $booster->tooltipSelector;
100 $afterAjaxUpdate =
"js:function() {
101 jQuery('.popover').remove();
102 jQuery('{$popover}').popover();
103 jQuery('.tooltip').remove();
104 jQuery('{$tooltip}').tooltip();
107 if (!isset($this->afterAjaxUpdate)) {
108 $this->afterAjaxUpdate = $afterAjaxUpdate;
119 foreach ($this->columns as
$i => $column) {
120 if (is_array($column) && !isset($column[
'class'])) {
121 $this->columns[
$i][
'class'] =
'booster.widgets.TbDataColumn';
127 if ($this->responsiveTable) {
128 $this->writeResponsiveCss();
144 if (!preg_match(
'/^([\w\.]+)(:(\w*))?(:(.*))?$/', $text, $matches)) {
145 throw new CException(Yii::t(
147 'The column must be specified in the format of "Name:Type:Label", where "Type" and "Label" are optional.'
152 $column->name = $matches[1];
154 if (isset($matches[3]) && $matches[3] !==
'') {
155 $column->type = $matches[3];
158 if (isset($matches[5])) {
159 $column->header = $matches[5];
170 protected function writeResponsiveCss()
174 foreach ($this->columns as $column) {
177 $column->renderHeaderCell();
178 $name = strip_tags(ob_get_clean());
180 $labels .=
"#$this->id td:nth-of-type($cnt):before { content: '{$name}'; }\n";
186 only screen and (max-width: 760px),
187 (min-device-width: 768px) and (max-device-width: 1024px) {
190 #{$this->id} table,#{$this->id} thead,#{$this->id} tbody,#{$this->id} th,#{$this->id} td,#{$this->id} tr {
195 #{$this->id} thead tr {
201 #{$this->id} tr { border: 1px solid #ccc; }
206 border-bottom: 1px solid #eee;
211 #{$this->id} td:before {
221 .grid-view .button-column {
231 Yii::app()->clientScript->registerCss(__CLASS__ .
'#' . $this->
id, $css);