Yii2: Ajax Gridview

Want to navigate through the grids or trying to sort and filter data without waiting for the entire page to load?

You need yii\widgets\Pjax and wrap it around GridView.

In the view:

use yii\grid\GridView;
use yii\widgets\Pjax;
echo GridView::widget([

This will cause all actions within the Grid to run in Ajax mode, including links.

To exclude links from being processed by Pjax, add data-pjax="0" (zero) to the <a>.

Alternative Solution

Use the extend grid widget, which extra some cool additional properties to the built-in GridView, including Pjax. Simply add pjax property to the grid:

use kartik\grid\GridView;
echo GridView::widget([
    'pjax' => true,

Leave a Reply

Your email address will not be published. Required fields are marked *