Pjax-Redirecting whole page while clicking in page number of yii2 grid view listing

570 views Asked by At

Actually I am listing the companies in modalbox, and there is a search facility. When clicking in page number (pager) it gets redirected and whole modalbox becomes new view - what i want is if i click on page number it should list data with out redirecting. Sometime it works as intended. The code is as below, can anybody suggest me what should I do right here.

{% set pjax = pjax_begin({
'enablePushState': false,
'enableReplaceState':false,
'options': {'id': 'pjax-company-list', 'class': 'clearfix'}
}) %}

{{ use('yii/widgets/ActiveForm') }}
{% set form = active_form_begin({
'id' : 'campaign-add-company-form',
'options' : {'class' : 'campaign-add-company-form ajaxForm'},
}) %}
{{ use('yii/bootstrap/Tabs') }}

{% set columns = [
{
'class' : '\\yii\\grid\\CheckboxColumn',
},
'etternavn',
'kundenr',
'orgnr',
'web',
'gateadr',
'telefon',
{
'class' : '\\common\\grid\\EvalColumn',
'value': 'function($data){
                    $res = "";

                    if (isset($data->status)) {
                        $res = $data->status->statusbeskrivelse . "<br>";
                    }
                    return $res;
                        }',
'header': 'Status',
},
] %}

{{ use('yii/grid/GridView') }}
{{ grid_view_widget({
    'id': 'campaign-add-companies',
    'tableOptions': { 'class':  'table table-hover'},
    'layout': "<div class=\"table-responsive\">{items}</div>{summary}<div class=\"pull-right\">{pager}</div>",
    'dataProvider': dataProvider,
    'columns': columns
}) }}

{{ active_form_end() }}

{% set pjax = pjax_end() %}
1

There are 1 answers

0
Veshraj Joshi On BEST ANSWER

After two day I suspect on timeout property and track down the error occured in pjax, and track down the error with code like-

$('body').on('click', '#pjax-company-list .pagination li > a', function() {
    $('#pjax-error').html('');
});

$('#pjax-company-list').on('pjax:error', function (event, error) {
    $('#pjax-error').html('Process is aborted due to timeout. Please try again.');
    event.stopImmediatePropagation();
    event.preventDefault();
 });

and initiate pjax with following

 {% set pjax = pjax_begin({
   'enablePushState': false,
   'timeout':100000,
   'options': {'id': 'pjax-company-list', 'class': 'clearfix'}
 }) %}