在Yii2中使用PJAX的Listview过滤器无法正常工作

时间:2017-09-19 15:34:03

标签: listview yii2 pjax

我在listview上为某些参数设置了一个过滤器。过滤器正在运行,但即使我使用Pjax,整个页面也会重新加载。我甚至试图增加pjax超时而没有成功。

这是控制器:

public function actionArticles()
{
    $articleSearch = new ArticleSearch();
    $articleDataProvider = $articleSearch ->search(Yii::$app->request->post());

    return $this->render('list', ['articleSearch ' => $articleSearch ,
                                     'articleDataProvider ' => $articleDataProvider ]);
}

以下是观点:

<?php Pjax::begin(['id' => 'pjax_list_articles', 
                   'timeout' => false, 
                   'clientOptions' => ['method' => 'POST']]); ?> 

<?php $mapCategories = ArrayHelper::map(Category::find()->orderby('cName ASC')->all(); ?>

<div class="filter_form">   

<?php $form = ActiveForm::begin([
    'id' => 'search_form',
    'method' => 'post',
    'enableAjaxValidation'=>false,
    'enableClientValidation'=>false,
    'options' => ['class' => 'form-horizontal'], 
]); ?>

    <?= $form->field($articleSearch , 'aCategory')
            ->dropDownList( $mapCategories ,'cID', 'cName'), 
                        ['prompt'=> Yii::t('app', 'All categories'), 
                         'onchange'=>'this.form.submit()'
                        ] )
            ->label(false) 
    ?>  

<?php ActiveForm::end() ?>  

</div>


<div class="listView_container">

    <?= 
        ListView::widget([

            'dataProvider' => $articleDataProvider ,

            'layout' => "{items}\n{pager}",

            'itemView' => function ($model, $key, $index, $widget) {
                return $this->render('_article_view',['model' => $model]);
            },

            'pager' => [
                        'firstPageLabel' => Yii::t('main','first'),
                        'lastPageLabel' => Yii::t('main','last'),
                        'prevPageLabel' => Yii::t('main','previous'),
                        'nextPageLabel' => Yii::t('main','next'),
                        'maxButtonCount' => 3,
                    ],

            'emptyText' => $emptyText,

        ]);
    ?>

</div>

<?php Pjax::end(); ?>

过滤器正在运行但重新加载整个页面。 我做错了什么?

0 个答案:

没有答案