gridview pjax reload

Hi everyone,

I am having trouble getting the Gridview to work. I have setup an action column which return this button:


return '<span id="request-wrap'.$key.'">'.Html::a('<i class="gridBtn fa fa-bell"></i>', ['approval', 'id'=>$model->id], [

                                'id' => 'request-link'.$key,

                                'class' => 'requestBtn',

                                'title' => Yii::t('yii', 'request'),

                                'data-id' => $key,

                                'data-pjax' => '1',

                            ]).'</span>';

the approval action is beeing run:





public function actionApproval($id){

        $model = $this->findModel($id);

        // action code ....


 

        // what to return here to make my pjax widget reload the grid?<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/huh.gif' class='bbc_emoticon' alt='???' />

        Yii::$app->response->format = Response::FORMAT_JSON;

        return ['forceReload'=>'#crud-datatable-pjax'];

    }




I just don’t know what I have to return from my controller to make the pjax widget reload. Can anyone help me with this please?

Thanks a lot.

Seb

Maybe if you capture the Json response with some value. (reload- not reload) You could run this JS line for reload grid.




  $.pjax.reload({container:'#your-id-pjax-grid', scrollTo:false});



regards,

thanks :) after looking for 3 days I finally figured it out.

For anyone wondering about it, this I had to place right above my gridview widget:





$script = <<< JS

    $(document).on("ready pjax:end", function() {

        $('.requestBtn').click(function(e) {

            $.ajax({

                type: "POST",

                url: "approval",

                data: {id: $(this).closest('tr').data('key')},

                success: function (test) {

                    $.pjax.reload({container: '#crud-datatable-pjax'});

                },

            });


            e.preventDefault();

        });

    });

JS;

$this->registerJs($script, View::POS_END); ?>




Cheers,

Seb