LinkSorter will generate a hyperlink for every attribute declared in [[sort]]. For more details and usage information on LinkSorter, see the guide article on sorting.
Since: 2.0
Author: Qiang Xue (qiang.xue@gmail.com)
Inheritance: extends yii\base\Widget
Exemple #1
0
 /**
  * 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);
 }
Exemple #2
0
 /**
  * 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])) : '';
 }
Exemple #3
0
 public function run()
 {
     if ($this->show) {
         parent::run();
     }
 }
Exemple #4
0
<?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 />