コード例 #1
0
ファイル: SnapGridView.php プロジェクト: snapfrozen/snapcms
 public function init()
 {
     $this->setFormatter(new SnapFormatter());
     parent::init();
     $this->snapBaseScriptUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('snapcms.widgets.assets')) . '/snapgridview';
     if ($this->selectableColumns === true) {
         $cs = Yii::app()->getClientScript();
         $cs->registerScriptFile($this->snapBaseScriptUrl . '/jquery.snapgridview.js', CClientScript::POS_END);
         $cs->registerCssFile($this->snapBaseScriptUrl . '/styles.css');
         if (empty($this->afterAjaxUpdate)) {
             $this->afterAjaxUpdate = "\$.fn.snapGridView.init";
         }
         $this->_setSelectedColumns();
         foreach ($this->columns as $pos => $column) {
             if (is_subclass_of($column, 'CDataColumn')) {
                 //populate the _selectableColumnsList used for generating checkboxes
                 $this->_selectableColumnsList[$column->name] = $column->header ? $column->header : $this->dataProvider->model->getAttributeLabel($column->name);
                 //remove any columns that arent' selected
                 if (!in_array($column->name, $this->selectedColumns)) {
                     unset($this->columns[$pos]);
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: BootSelGridView.php プロジェクト: postfx/fermion
 /**
  * Registers necessary client scripts. 
  * Automaticlly prepend user's beforeajaxUpdate with needed code that will modify GET params when navigating and sorting
  */
 public function registerClientScript()
 {
     parent::registerClientScript();
     if ($this->selectableRows > 0) {
         $id = $this->getId();
         $options = array('selVar' => $this->selVar);
         $options = CJavaScript::encode($options);
         $cs = Yii::app()->getClientScript();
         $cs->registerScriptFile($this->selBaseScriptUrl . '/jquery.selgridview.js', CClientScript::POS_END);
         $cs->registerScript(__CLASS__ . '#' . $id . '-sel', "jQuery('#{$id}').selGridView({$options});");
     }
 }