Inheritance: extends CGridView
Exemplo n.º 1
0
 public function renderTableBody()
 {
     if (!empty($this->mergeColumns) || !empty($this->extraRowColumns)) {
         $this->groupByColumns();
     }
     parent::renderTableBody();
 }
Exemplo n.º 2
0
 public function initColumns()
 {
     $this->dataProvider->model->onBeforeGridInitColumns(new CModelEvent($this));
     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();
     $this->dataProvider->model->onAfterGridInitColumns(new CModelEvent($this));
 }
Exemplo n.º 3
0
 public function initColumns()
 {
     if ($this->sortable === true) {
         $exists = false;
         foreach ($this->columns as $column) {
             if (isset($column['class']) && $column['class'] == 'ext.sortable.SortableColumn') {
                 $exists = true;
             }
         }
         if ($exists === false) {
             array_push($this->columns, array('class' => 'ext.sortable.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();
 }
Exemplo n.º 4
0
 public function init()
 {
     if (!isset($this->pages[0])) {
         $this->pages = array(10);
     }
     $size = $this->defaultSize;
     if (isset($_COOKIE[$this->cookey]) && isset($_REQUEST[$this->sizeParam]) && $_COOKIE[$this->cookey] != $_REQUEST[$this->sizeParam]) {
         setcookie($this->cookey, $_REQUEST[$this->sizeParam], time() + 2592000, "/");
         $size = $_REQUEST[$this->sizeParam];
     } else {
         if (!isset($_COOKIE[$this->cookey])) {
             setcookie($this->cookey, isset($_REQUEST[$this->sizeParam]) ? $_REQUEST[$this->sizeParam] : $this->defaultSize, time() + 2592000, "/");
             $size = isset($_REQUEST[$this->sizeParam]) ? $_REQUEST[$this->sizeParam] : $this->defaultSize;
         } else {
             if (isset($_COOKIE[$this->cookey])) {
                 $size = $_COOKIE[$this->cookey];
             }
         }
     }
     $this->dataProvider->pagination->pageSize = $size;
     $this->currentSize = $size;
     parent::init();
 }
Exemplo n.º 5
0
 public function renderSummary()
 {
     if (!$this->json) {
         parent::renderSummary();
         return true;
     }
     if (!$this->_showSummary) {
         return null;
     }
     ob_start();
     parent::renderSummary();
     $summary = ob_get_clean();
     return array('class' => $this->summaryCssClass, 'text' => $summary);
 }
Exemplo n.º 6
0
 /**
  *### .renderTableHeader()
  *
  * Renders grid header
  */
 public function renderTableHeader()
 {
     $this->renderChart();
     parent::renderTableHeader();
 }
 /**
  * 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.TbJsonDataColumn';
         }
     }
     parent::initColumns();
 }
Exemplo n.º 8
0
 /**
  *
  */
 public function run()
 {
     if ($this->multiActions || $this->gridActions || $this->gridButtons) {
         echo CHtml::openTag('div', array('id' => $this->id . '-multi-checkbox', 'class' => 'multi-checkbox-table')) . "\n";
         echo CHtml::beginForm('', 'POST', array('id' => $this->id . '-form'));
         echo CHtml::hiddenField('returnUrl', Yii::app()->returnUrl->getFormValue(true));
     }
     parent::run();
     if ($this->multiActions || $this->gridActions || $this->gridButtons) {
         echo CHtml::endForm();
         echo CHtml::closeTag('div');
     }
 }
Exemplo n.º 9
0
 /**
  * injects ajaxUpdate event into widget
  *
  * @param TbGridView $widget
  */
 public static function attachAjaxUpdateEvent($widget)
 {
     $trigger = '$("#' . $widget->id . '").trigger("ajaxUpdate.editable");';
     //check if trigger already inserted by another column
     if (strpos($widget->afterAjaxUpdate, $trigger) !== false) {
         return;
     }
     //inserting trigger
     if (strlen($widget->afterAjaxUpdate)) {
         $orig = $widget->afterAjaxUpdate;
         if (strpos($orig, 'js:') === 0) {
             $orig = substr($orig, 3);
         }
         $orig = "\n({$orig}).apply(this, arguments);";
     } else {
         $orig = '';
     }
     $widget->afterAjaxUpdate = "js: function(id, data) {\n            {$trigger} {$orig}\n        }";
     $widget->registerClientScript();
 }
Exemplo n.º 10
0
 public function run()
 {
     if ($this->grid_mode == 'export') {
         $this->renderHeader();
         $row = $this->renderBody();
         $this->renderFooter($row);
         //set auto width
         if ($this->autoWidth) {
             foreach ($this->columns as $n => $column) {
                 $this->objPHPExcel->getActiveSheet()->getColumnDimension($this->columnName($n + 1))->setAutoSize(true);
             }
         }
         //create writer for saving
         $objWriter = PHPExcel_IOFactory::createWriter($this->objPHPExcel, $this->exportType);
         if (!$this->stream) {
             $objWriter->save($this->filename);
         } else {
             //output to browser
             if (!$this->filename) {
                 $this->filename = $this->title;
             }
             $this->cleanOutput();
             header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
             header('Pragma: public');
             header('Content-type: ' . $this->mimeTypes[$this->exportType]['Content-type']);
             header('Content-Disposition: attachment; filename="' . $this->filename . '.' . $this->mimeTypes[$this->exportType]['extension'] . '"');
             header('Cache-Control: max-age=0');
             $objWriter->save('php://output');
             Yii::app()->end();
         }
     } else {
         parent::run();
     }
 }
Exemplo n.º 11
0
 /**
  * Registers necessary client scripts.
  */
 public function registerClientScript()
 {
     //Call parent
     parent::registerClientScript();
     if ($this->enableDragDropSorting === true) {
         $cs = Yii::app()->getClientScript();
         //Register jquery-ui
         $cs->registerCoreScript('jquery.ui');
         //Register sort script
         $cs->registerScript(__CLASS__ . '-' . $this->id, $this->getSortScript() . '
         $("body").ajaxSuccess(function(e, xhr, settings) {
            if (settings.url === $.fn.yiiGridView.getUrl(' . Cjavascript::encode($this->getId()) . ')) {
               ' . $this->getSortScript() . '
            }
         });
   ');
     }
 }
Exemplo n.º 12
0
 /**
  * Creates column objects and initializes them.
  */
 protected function initColumns()
 {
     parent::initColumns();
     if ($this->responsiveTable) {
         $this->attachBehavior('ywresponsive', array('class' => 'yiiwheels.widgets.grid.behaviors.WhResponsive'));
         $this->writeResponsiveCss($this->columns, $this->id);
     }
 }
Exemplo n.º 13
0
 /**
  * Изначально регистрируются 2 плагина gridBase и grid
  * Если установить значение свойства jsPlugin, то подключится так же плагин /css/admin/gridview/grid.js
  * И на сам grid будет инициализироват плагин с названием из jsPlugin
  */
 public function registerClientScript()
 {
     parent::registerClientScript();
     $cs = Yii::app()->clientScript;
     $cs->registerCoreScript('jquery.ui');
     $cs->registerScriptFile("/js/plugins/gridview/gridBase.js");
     $cs->registerScriptFile("/js/plugins/gridview/grid.js");
     $options = CJavaScript::encode(array('mass_removal' => $this->mass_removal, 'filter_hint' => $this->filter_hint));
     $cs->registerScript($this->getId() . '.grid', "\r\n            \$('#{$this->getId()}').grid({$options});\r\n        ");
     $this->onRegisterScript(new CEvent());
 }
 public function init()
 {
     // check if a cookie exist holding some options and explode it into GET
     // must be done before parent::init(), because it calls initColumns
     // and it calls dataProvider->getData(), not done if options are passed through GET/POST
     if (isset($this->options['bStateSave']) && $this->options['bStateSave']) {
         $cookiePrefix = isset($this->options['sCookiePrefix']) ? $this->options['sCookiePrefix'] : 'edt_';
         self::restoreState($this->getId(), $cookiePrefix);
     }
     parent::init();
 }