Latest news:

Sahih al-Bukhari (সহীহ বুখারী) is a free Hadith application for android. This application is advertisement free. Download now

Yii2 GridView sorting and pagination using pajax

Yii2 GridView sorting and pagination using pajax

In this article we will learn how to use Pjax for Yii2 grid view sorting and pagination.

Pjax is a jquery plugin which progressively enhances website page loads and behave more like single-page web application.

We need to these steps to enable Pjax in yii2 web page

  • Import yii\widgets\Pjax class
  • Begin Pjax widget using Pjax::begin()
  • Code block which needs to be rendered using Pjax
  • Close Pjax widget  Pjax::end()

Below code is the example of how to use pjax for yii2 grid view sorting and pagination

use yii\widgets\Pjax

Add above line in the beginning of your view. 

    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'columns' => [
        ['class' => 'yiigridSerialColumn'],
            'class' => 'yiigridActionColumn',
            'template' => '{view}',

Tags : PHP, Yii2,

Views : 1613

Subscribe Us

Follow Us