No Ajax In Gridview?

I implemented the yii\grid\GridView::widget(), but, like in Yii 1.x, there is no ajax been used for sorting and pagination? Am i missing something?

Are you sure ajax isn’t working?

Are there any errors in your browser’s console?

Can you show the code you’re using?

Yes i’m sure, i already mentioned the enableAjaxValidation in ActiveForm in my frontend application doesn’t work as well (no ajax call has been made while submitting the form). No errors in my console.

This is my code:


<?php echo GridView::widget([

                'dataProvider' => $dataProvider,

                'columns' => [

                    ['class' => 'yii\grid\CheckboxColumn'],


                    'id',

                    'username',

                    'email',

                    'addTime',

                    // 'accountStatus:boolean',

                    // 'accountType:boolean',

                    // 'gender:boolean',

                    // 'dateOfBirth',

                    // 'countryId',

                    // 'regionId',

                    // 'cityId',

                    // 'lastSeen',


                    ['class' => 'yii\grid\ActionColumn'],

                ],

            ]); ?>

Before ‘</body>’:


  <script src="/cpanel/assets/bc4b412f/jquery.js"></script>

<script src="/cpanel/assets/b304dad1/yii.js"></script>

<script src="/cpanel/assets/b304dad1/yii.gridView.js"></script>

<script type="text/javascript">jQuery(document).ready(function(){

jQuery('#w0').yiiGridView({"filterUrl":"\/cpanel\/index.php?r=user\/index","filterSelector":"#w0-filters input, #w0-filters select"});

jQuery('#w0').yiiGridView('setSelectionColumn', {"name":"selection[]","multiple":true,"checkAll":"selection_all"});

});</script>

Is the problem present in different browsers?

Yes, in Chrome and Firefox i got the same problem.

I did a fresh install of Yii 2, created a model with Gii, created the controllers & views with the CRUD generator.

When I visit the page (user/index) with the gridview, sorting and stuff is still not done with AJAX. When i type something in the filter boxes and click outside the input field, the website is redirecting (so the Javascript part works), but not with AJAX.

When i’m putting $.post(‘test’); in my script it works fine.

Can someone please help me debugging this problem? What javascript function / event is called in yii.gridView.js when sorting?

The current GridView doesn’t support AJAX. We plan to include a Pjax widget which can support ajax in a more systematic way.

Oh i see, that makes clear a lot ;). Thanks anyway.

I see that Pjax widget has now been implemented. Is this going to be the standard way of doing ajax GridView in Yii2? Would there be any other way of doing ajax GridView?