init() public method

Initializes the widget.
public init ( )
Example #1
0
    public function init()
    {
        $this->attachBehaviors($this->behaviors());

        if (!isset($this->htmlOptions['class']))
        {
            $this->htmlOptions['class'] = 'grid-view';
        }

        if (!isset($this->htmlOptions['id']))
        {
            $this->htmlOptions['id'] = $this->getId();
        }

        if ($this->baseScriptUrl === null)
        {
            $this->baseScriptUrl = Yii::app()->getAssetManager()
                ->publish(Yii::getPathOfAlias('application.components.zii.assets')) .
                '/adminGrid';
        }

        if ($this->cssFile !== false)
        {
            if ($this->cssFile === null)
            {
                $this->cssFile = $this->baseScriptUrl . '/styles.css';
            }
            Yii::app()->getClientScript()->registerCssFile($this->cssFile);
        }

        parent::init();
        $this->formatDateValues();
    }
Example #2
0
 public function init()
 {
     if (isset($_GET[$this->grid_mode_var])) {
         $this->grid_mode = $_GET[$this->grid_mode_var];
     }
     if (isset($_GET['exportType'])) {
         $this->exportType = $_GET['exportType'];
     }
     $lib = Yii::getPathOfAlias($this->libPath) . '.php';
     if ($this->grid_mode == 'export' and !file_exists($lib)) {
         $this->grid_mode = 'grid';
         Yii::log("PHP Excel lib not found({$lib}). Export disabled !", CLogger::LEVEL_WARNING, 'EExcelview');
     }
     if ($this->grid_mode == 'export') {
         $this->title = $this->title ? $this->title : Yii::app()->getController()->getPageTitle();
         $this->initColumns();
         //parent::init();
         //Autoload fix
         spl_autoload_unregister(array('YiiBase', 'autoload'));
         Yii::import($this->libPath, true);
         $this->objPHPExcel = new PHPExcel();
         spl_autoload_register(array('YiiBase', 'autoload'));
         // Creating a workbook
         $this->objPHPExcel->getProperties()->setCreator($this->creator);
         $this->objPHPExcel->getProperties()->setTitle($this->title);
         $this->objPHPExcel->getProperties()->setSubject($this->subject);
         $this->objPHPExcel->getProperties()->setDescription($this->description);
         $this->objPHPExcel->getProperties()->setCategory($this->category);
     } else {
         parent::init();
     }
 }
 /**
  * Initializes $json property to find out whether ajax request or not
  */
 public function init()
 {
     // parse request to find out whether is an ajax request or not, if so, then return $dataProvider JSON formatted
     $this->json = Yii::app()->getRequest()->getIsAjaxRequest();
     if ($this->json) {
         $this->template = '{items}';
     }
     // going to render only items!
     parent::init();
 }
Example #4
0
 /**
  * Widget initialization
  */
 public function init()
 {
     parent::init();
     /**
      * check whether we have extraRowColumns set, forbid filters
      */
     if (!empty($this->extraRowColumns)) {
         foreach ($this->columns as $column) {
             if ($column instanceof CDataColumn && in_array($column->name, $this->extraRowColumns)) {
                 $column->filterHtmlOptions = array('style' => 'display:none');
                 $column->filter = false;
             }
         }
     }
     /**
      * setup extra row options
      */
     if (isset($this->extraRowHtmlOptions['class']) && !empty($this->extraRowCssClass)) {
         $this->extraRowHtmlOptions['class'] .= ' ' . $this->extraRowCssClass;
     } else {
         $this->extraRowHtmlOptions['class'] = $this->extraRowCssClass;
     }
 }
Example #5
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();
 }
Example #6
0
 /**
  *### .init()
  *
  * Widget initialization
  */
 public function init()
 {
     if (preg_match('/extendedsummary/i', $this->template) && !empty($this->extendedSummary) && isset($this->extendedSummary['columns'])) {
         $this->template .= "\n{extendedSummaryContent}";
         $this->displayExtendedSummary = true;
     }
     if (!empty($this->chartOptions) && @$this->chartOptions['data'] && $this->dataProvider->getItemCount()) {
         $this->displayChart = true;
     }
     if ($this->bulkActions !== array() && isset($this->bulkActions['actionButtons'])) {
         if (!isset($this->bulkActions['class'])) {
             $this->bulkActions['class'] = 'bootstrap.widgets.TbBulkActions';
         }
         $this->bulk = Yii::createComponent($this->bulkActions, $this);
         $this->bulk->init();
     }
     parent::init();
 }
Example #7
0
 /**
  *
  */
 public function init()
 {
     // pager labels
     if (!isset($this->pager['firstPageLabel'])) {
         $this->pager['firstPageLabel'] = '<i class="icon-fast-backward"></i>';
     }
     if (!isset($this->pager['lastPageLabel'])) {
         $this->pager['lastPageLabel'] = '<i class="icon-fast-forward"></i>';
     }
     if (!isset($this->pager['nextPageLabel'])) {
         $this->pager['nextPageLabel'] = '<i class="icon-forward"></i>';
     }
     if (!isset($this->pager['prevPageLabel'])) {
         $this->pager['prevPageLabel'] = '<i class="icon-backward"></i>';
     }
     if (!isset($this->pager['maxButtonCount'])) {
         $this->pager['maxButtonCount'] = 5;
     }
     if (!isset($this->pager['displayFirstAndLast'])) {
         $this->pager['displayFirstAndLast'] = true;
     }
     // userPageSize drop down changed
     $this->setUserPageSize();
     // set pagination
     $this->dataProvider->pagination->pageSize = $this->getUserPageSize();
     // add checkbox when we have multiactions
     if ($this->multiActions) {
         $this->columns = CMap::mergeArray(array(array('class' => 'CCheckBoxColumn')), $this->columns);
     }
     parent::init();
 }
Example #8
0
 /**
  * Widget initialization
  */
 public function init()
 {
     if (preg_match('/extendedsummary/i', $this->template) && !empty($this->extendedSummary) && isset($this->extendedSummary['columns'])) {
         $this->template .= "\n{extendedSummaryContent}";
         $this->displayExtendedSummary = true;
     }
     if (!empty($this->chartOptions) && @$this->chartOptions['data'] && $this->dataProvider->getItemCount()) {
         $this->displayChart = true;
     }
     parent::init();
 }
 /**
  * Initializes the grid view.
  * This method will initialize required property values and instantiate {@link columns} objects.
  */
 public function init()
 {
     if ($this->enableDragDropSorting === true) {
         /*To use this widget, data provider must be an instance of CActiveDataProvider*/
         if (!$this->dataProvider instanceof CActiveDataProvider) {
             throw new CException(Yii::t('zii', 'Data provider must be an instance of CActiveDataProvider'));
         }
         if ($this->allItemsInOnePage === true) {
             $this->dataProvider->pagination = false;
         }
         $this->enableSorting = false;
         if ($this->descSort !== true) {
             $sort_direction = 'ASC';
         } else {
             $sort_direction = 'DESC';
         }
         $this->dataProvider->setSort(array('defaultOrder' => $this->dataProvider->model->tableAlias . '.' . $this->orderField . ' ' . $sort_direction));
     }
     parent::init();
 }
Example #10
0
 public function init()
 {
     $this->dataProvider->model->onBeforeGridInit(new CModelEvent($this));
     parent::init();
     $this->dataProvider->model->onAfterGridInit(new CModelEvent($this));
 }
Example #11
0
 /**
  * Widget initialization
  */
 public function init()
 {
     if (preg_match('/extendedsummary/i', $this->template) && !empty($this->extendedSummary) && isset($this->extendedSummary['columns'])) {
         $this->template .= "\n{extendedSummaryContent}";
         $this->displayExtendedSummary = true;
     }
     $this->attachBehavior('ywplugin', array('class' => 'yiiwheels.behaviors.WhPlugin'));
     $this->attachBehavior('ywchart', array('class' => 'yiiwheels.widgets.grid.behaviors.WhChart'));
     parent::init();
 }
    /**
     *### .init()
     *
     * Widget initialization
     */
    public function init()
    {
        if (preg_match('/extendedsummary/i', $this->template) && !empty($this->extendedSummary) && isset($this->extendedSummary['columns'])) {
            $this->template .= "\n{extendedSummaryContent}";
            $this->displayExtendedSummary = true;
        }
        if (!empty($this->chartOptions) && @$this->chartOptions['data'] && $this->dataProvider->getItemCount()) {
            $this->displayChart = true;
        }
        if ($this->bulkActions !== array() && isset($this->bulkActions['actionButtons'])) {
            if (!isset($this->bulkActions['class'])) {
                $this->bulkActions['class'] = 'booster.widgets.TbBulkActions';
            }
            $this->bulk = Yii::createComponent($this->bulkActions, $this);
            $this->bulk->init();
        }
        // if(isset($this->bulkActions['selectableEqualsChecked']) && $this->bulkActions['selectableEqualsChecked'] === true) {
        $this->selectionChanged = 'js:function(id) {
				$("#"+id+" input[type=checkbox]").change();
			}';
        // }
        parent::init();
    }
 /**
  *### .init()
  *
  * Widget initialization
  */
 public function init()
 {
     if ($this->shouldEnableExtendedSummary()) {
         $this->prepareDisplayingExtendedSummary();
     }
     if ($this->shouldEnableChart() && $this->hasData()) {
         $this->enableChart();
     }
     if ($this->shouldEnableBulkActions()) {
         $this->enableBulkActions();
     }
     $this->fillSelectionChangedProperty();
     parent::init();
 }
 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();
 }