Пример #1
0
 public function registerClientScript()
 {
     if (!Yii::app()->request->isAjaxRequest) {
         parent::registerClientScript();
         $cs = Yii::app()->clientScript;
         $basePath = Yii::getPathOfAlias('ext.NPager.assets');
         $baseUrl = Yii::app()->getAssetManager()->publish($basePath);
         $id = parent::getId();
         $cs = Yii::app()->clientScript;
         $cs->registerCoreScript('jquery');
         $js = "function {$id}" . "_changePageSize(id,url)\n";
         $js .= "{\n";
         $js .= "    url = {url:url+\$('#'+id+'>.{$this->pagerlistCssClass}>select').val()};\n";
         $js .= "    \$.fn.yiiGridView.update(id,url);\n";
         $js .= "}\n";
         $js .= "\n";
         $cs->registerScript($this->getId(), $js, CClientScript::POS_END);
         $cs->registerCssFile($baseUrl . '/style.css');
     }
 }
Пример #2
0
 public function getId($autoGenerate = true)
 {
     static $hashes = [];
     if (parent::getId(false) == null && $autoGenerate) {
         // Generate a unique id that does not depend on the number of widgets on the page
         // but on the column configuration.
         if (isset($this->dataProvider->id)) {
             $hash = substr(md5(json_encode($this->columns)), 0, 5) . $this->dataProvider->id;
         } else {
             $hash = substr(md5(json_encode($this->columns)), 0, 5);
         }
         while (in_array($hash, $hashes)) {
             $hash = substr(md5($hash), 0, 5);
         }
         $hashes[] = $hash;
         $this->setId('dt_' . $hash);
     }
     return parent::getId($autoGenerate);
 }
Пример #3
0
 public function getId($autoGenerate = true)
 {
     if (isset($this->dataProvider->modelClass) && $this->genId) {
         return strtolower($this->dataProvider->modelClass) . '-grid';
     } else {
         return parent::getId($autoGenerate);
     }
 }