/** * Renders the sorter. * @return string the rendering result */ public function renderSorter() { $sort = $this->dataProvider->getSort(); if ($sort === false || empty($sort->attributes) || $this->dataProvider->getCount() <= 0) { return ''; } /* @var $class LinkSorter */ $sorter = $this->sorter; $class = ArrayHelper::remove($sorter, 'class', LinkSorter::className()); $sorter['sort'] = $sort; $sorter['view'] = $this->getView(); return $class::widget($sorter); }
/** * Renders sorter * @param array $options * @return string * @throws \Exception */ public function sorter($options = []) { return $this->_adp ? LinkSorter::widget(array_merge($options, ['sort' => $this->_adp->sort])) : ''; }
public function run() { if ($this->show) { parent::run(); } }
<?php use yii\widgets\LinkPager; use yii\widgets\LinkSorter; use yii\grid\GridView; ?> <?php echo LinkSorter::widget(['sort' => $sort]); ?> <?php foreach ($models as $model) { ?> <?php echo $model->id; } ?> <?php // display pagination echo LinkPager::widget(['pagination' => $pages]); ?> <br /> <br /> <br /> <hr /> <br />