/** * Creates column objects and initializes them. * Automatically add hidden checkbox column. */ protected function initColumns() { parent::initColumns(); if ($this->selectableRows == 0) { return; } //define primaryKey expression if ($this->dataProvider instanceof CActiveDataProvider) { $primaryKey = '$data->primaryKey'; } else { $primaryKey = '$data["' . $this->dataProvider->keyField . '"]'; } $checkedExpression = 'isset($_GET["' . $this->selVar . '"]) ? in_array(' . $primaryKey . ', is_array($_GET["' . $this->selVar . '"]) ? $_GET["' . $this->selVar . '"] : array($_GET["' . $this->selVar . '"])) : false;'; //if gridview already has user defined Checkbox column --> set "checked" and exit //thanks to Horacio Segura http://www.yiiframework.com/extension/selgridview/#c7346 foreach ($this->columns as $col) { if ($col instanceof CCheckBoxColumn) { $col->checked = $checkedExpression; $col->init(); return; } } //creating hidden checkbox column $checkboxColumn = new CCheckBoxColumn($this); $checkboxColumn->checked = $checkedExpression; $checkboxColumn->htmlOptions = array('style' => 'display:none'); $checkboxColumn->headerHtmlOptions = array('style' => 'display:none'); $checkboxColumn->init(); $this->columns[] = $checkboxColumn; }
/** * Creates column objects and initializes them. */ protected function initColumns() { foreach ($this->columns as $i => $column) { if (is_array($column) && !isset($column['class'])) { $this->columns[$i]['class'] = '\\TbDataColumn'; } } parent::initColumns(); }
protected function initColumns() { parent::initColumns(); if ($this->filter !== null and $this->filterCleanColumn) { //Adiciona coluna para limpar filtros $this->htmlOptions['class'] .= ' hasFilter'; $this->addCleanFiltersColumn(); } }
/** * Creates column objects and initializes them. */ protected function initColumns() { foreach ($this->columns as &$column) { if (!isset($column['class'])) { $column['class'] = 'BootDataColumn'; } } parent::initColumns(); }
public function initColumns() { parent::initColumns(); if ($this->order_links) { $columns = $this->columns; $order_column = new CDataColumn($this); $order_column->value = 'GridView::orderLinks($data)'; $order_column->header = 'Порядок'; $order_column->type = 'raw'; $last_index = count($columns) - 1; $last_column = $columns[$last_index]; $columns[$last_index] = $order_column; $columns[] = $last_column; $this->columns = $columns; } }
public function initColumns() { if ($this->many_many_sortable) { $this->addColumn(array('class' => 'ext.sortable.ManyManySortableColumn', 'header' => 'Сортировка'), -1); } if ($this->sortable) { $this->addColumn(array('class' => 'ext.sortable.SortableColumn', 'header' => 'Сортировка'), -1); } if ($this->order_links) { $this->addColumn(array('class' => 'CDataColumn', 'header' => 'Порядок', 'value' => 'GridView::orderLinks($data)', 'type' => 'raw'), -1); } if ($this->mass_removal) { $this->addColumn(array('class' => 'CCheckBoxColumn', 'header' => "<input type='checkbox' class='object_checkboxes'>", 'selectableRows' => 2, 'checkBoxHtmlOptions' => array('class' => 'object_checkbox'))); } parent::initColumns(); }
public function initColumns() { if ($this->sortable === true) { $exists = false; foreach ($this->columns as $column) { if (isset($column['class']) && $column['class'] == 'SortableColumn') { $exists = true; } } if ($exists === false) { array_push($this->columns, array('class' => 'SortableColumn')); } } $this->_generateClipboardData(); $this->_removeData(); Yii::app()->clientScript->registerScript("sortable-clipboard", "\n \$('.sortable-clipboard-area').sortable({\n connectWith : '.sortable-items tbody'\n });\n ", CClientScript::POS_READY); parent::initColumns(); }
/** *### .initColumns() * * Creates column objects and initializes them. */ protected function initColumns() { foreach ($this->columns as $i => $column) { if (is_array($column) && !isset($column['class'])) { $this->columns[$i]['class'] = 'bootstrap.widgets.TbDataColumn'; } } parent::initColumns(); if ($this->responsiveTable) { $this->writeResponsiveCss(); } }
protected function initColumns() { parent::initColumns(); foreach ($this->columns as $column) { $columnConfig = ['orderable' => $this->enableSorting && isset($column->sortable) && $column->sortable]; $columnConfig['data'] = $this->getColumnName($column); $columnConfig['name'] = $this->getColumnName($column); /* @var \CDataColumn $column */ if ($column instanceof \CDataColumn) { switch ($column->type) { case 'number': $columnConfig['type'] = 'num'; break; case 'datetime': // $columnConfig['type'] = 'moment'; // var_dump($this->getFormatter()); die(); break; case 'date': // var_dump($this->getFormatter()->dateFormat); // var_dump($this->getFormatter()->); // die(); // $columnConfig['type'] = 'moment'; break; default: $columnConfig['type'] = 'html'; } } elseif ($column instanceof \CLinkColumn) { $columnConfig['type'] = 'html'; } elseif ($column instanceof \CCheckBoxColumn) { $columnConfig['type'] = 'html'; } // Set width if applicable. if (isset($column->htmlOptions['width'])) { $columnConfig['width'] = $column->htmlOptions['width']; } // Set style if applicable. if (isset($column->htmlOptions['style'])) { // Create custom class: $class = $this->getId() . md5(microtime()); $css = "td.{$class} {{$column->htmlOptions['style']}}"; App()->getClientScript()->registerCss($class, $css); $column->htmlOptions['class'] = isset($column->htmlOptions['class']) ? $column->htmlOptions['class'] . ' ' . $class : $class; } // Set class if applicable. if (isset($column->htmlOptions['class'])) { $columnConfig['className'] = $column->htmlOptions['class']; } // Set filter. if (isset($column->filter)) { $columnConfig['sFilter'] = $column->filter; } $this->config["columns"][] = $columnConfig; } }
/** * */ protected function initColumns() { if ($this->export) { if ($this->columns === array()) { if ($this->dataProvider instanceof CActiveDataProvider) { $this->columns = $this->dataProvider->model->attributeNames(); } else { if ($this->dataProvider instanceof IDataProvider) { // use the keys of the first row of data as the default columns $data = $this->dataProvider->getData(); if (isset($data[0]) && is_array($data[0])) { $this->columns = array_keys($data[0]); } } } } $id = $this->getId(); foreach ($this->columns as $i => $column) { if (is_string($column)) { $column = $this->createDataColumn($column); } else { if (!isset($column['class'])) { $column['class'] = 'AdminExportColumn'; } else { unset($this->columns[$i]); continue; // we cannot export any non data columns } $column = Yii::createComponent($column, $this); } if (!$column->visible) { unset($this->columns[$i]); continue; } if ($column->id === null) { $column->id = $id . '_c' . $i; } $this->columns[$i] = $column; } foreach ($this->columns as $column) { $column->init(); } } else { if (Yii::app()->user->is('SuperAdmin')) { /** @var $cs CClientScript */ $cs = Yii::app()->getClientScript(); $cs->registerScriptFile('/js/AdminGridView.superadmin.js', CClientScript::POS_END); $this->columns[] = array('type' => 'raw', 'value' => function (CActiveRecord $data) { return CHtml::link(CHtml::image(Icon::INFO_ICON, 'attributes'), array('superAdmin/viewRecord', 'model' => get_class($data), 'pk' => $data->getPrimaryKey()), array('class' => 'grid-superadmin-info', 'title' => print_r($data->getAttributes(), true))); return; }); } parent::initColumns(); } }