Answer the question
In order to leave comments, you need to log in
How to organize an ajax request, while updating via pjax, yii?
Hello.
You need to make a request, as I understand it ajax, and update the gridview with pjax.
The page has a dropdown list.
<div class="notes-form">
<?php Pjax::begin(['id' => 'driverPjax']) ?>
<?php $form = ActiveForm::begin(['options' => ['data-pjax' => true]]); ?>
<? $param = ['prompt' => 'Выберите водителя', 'id' => 'dropDownList-driver']; ?>
<?= Html::dropDownList('driver', 0, $Fio, $param); ?>
<?php ActiveForm::end(); ?>
<?php Pjax::end(); ?>
</div>
<?php Pjax::begin(['id' => 'notes']) ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'Fio',
'value' => function ($model) {
return $model->idDriver['Fio'];
}
],
'Cash',
'Date',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
<?php Pjax::end() ?>
Answer the question
In order to leave comments, you need to log in
If you need to refresh the gridview after submitting the form, then you can simply reload the PJAX container, like so:
$('#driverPjax').on('pjax:end', function() {
$.pjax.reload({
container : '#notes', timeout: '5000',
});
});
onChange = "$.pjax.reload({container : '#notes', timeout: '5000'});"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question