Answer the question
In order to leave comments, you need to log in
How in Yii2 custom filter _search file using pjax so that ListView and GridView are updated without page reload?
Good afternoon,
There is a controller:
public function actionIndex()
{
$searchModel = new OffersSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'dataProvider' => $dataProvider,
'searchModel' => $searchModel,
]);
}
<?php Pjax::begin(['id' => 'notes']) ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'name',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
<?php Pjax::end() ?>
$("#search_note").on("pjax:end", function() {
$.pjax.reload({
container:"#notes"
});
});
<?php yii\widgets\Pjax::begin(['id' => 'search_note']) ?>
<?php $form = ActiveForm::begin([
'options' => ['data-pjax' => true ],
'method' => 'post',
]); ?>
...
<?= $form->field($model, 'id')->textInput([
'type'=>'number'
]) ?>
...
<?= Html::submitButton(Yii::t('app', Yii::t('app','search')), ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton(Yii::t('app', Yii::t('app','reset')), ['class' => 'btn btn-default']) ?>
<?php ActiveForm::end(); ?>
<?php yii\widgets\Pjax::end() ?>
'method' => 'post',
'method' => 'get',
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question