不重新加载页面的Yii2搜索表单
我有一个选项卡布局的页面。我为gridview构建了一个搜索表单。但每次我使用搜索时,它都会重新加载页面并将我带回第一个选项卡。我怎样才能解决这个问题 这是我的密码:不重新加载页面的Yii2搜索表单,yii2,yii2-basic-app,Yii2,Yii2 Basic App,我有一个选项卡布局的页面。我为gridview构建了一个搜索表单。但每次我使用搜索时,它都会重新加载页面并将我带回第一个选项卡。我怎样才能解决这个问题 这是我的密码: <?php $form = ActiveForm::begin([ 'options' => ['data-pjax' => true ], 'action' => ['index'], 'method' => 'get', ]); ?> Approv
<?php $form = ActiveForm::begin([
'options' => ['data-pjax' => true ],
'action' => ['index'],
'method' => 'get',
]); ?>
Approve month: <input type="string" name="approvemonth"><br><br>
Team: <input type="string" name="team"><br><br>
Difficulty: <input type="string" name="difficulty">
<div class="form-group">
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
</div>
<?php ActiveForm::end(); ?>
<?php echo GridView::widget([
'dataProvider' => $dataProvider15,
'filterModel' => true,
'pjax'=>true,
'panel' => [
'type' => GridView::TYPE_PRIMARY,
'heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-user"></i>Avg total time by modeler without handover</h3>',
],
'columns' => [
[
'attribute'=>'approvemonth',
'filter' => Html::input('string', 'approvemonth'),
[
'attribute' =>'team',
'filter' => Html::input('string', 'team'),
// 'group' => true,
],
[
'attribute' =>'difficulty',
'filter' => Html::input('string', 'difficulty'),
// 'group' => true,
],
[
'attribute' =>'Total',
'format'=>['decimal',2]
],
[
'attribute' =>'Avg',
'format'=>['decimal',2]
],
]
]);
?>
批准月份:
团队:
困难:
这是因为您没有将表单包装在
<?php Pjax::begin()?>
<?php Pjax::end()?>
我可以看到您如何在上面的代码中使用Pjax,添加更新的代码非常感谢:)我的问题是我在表单之后使用Pjax::end(),而不是覆盖整个表。非常感谢。
<?php \yii\widgets\Pjax::begin();?>
<?php $form = ActiveForm::begin([
'options' => ['data-pjax' => true],
'action' => ['index'],
'method' => 'get',
]);?>
Approve month: <input type="string" name="approvemonth"><br><br>
Team: <input type="string" name="team"><br><br>
Difficulty: <input type="string" name="difficulty">
<div class="form-group">
<?=Html::submitButton('Search', ['class' => 'btn btn-primary'])?>
<?=Html::resetButton('Reset', ['class' => 'btn btn-default'])?>
</div>
<?php ActiveForm::end();?>
<?php echo GridView::widget([
'dataProvider' => $dataProvider15,
'filterModel' => true,
'pjax' => true,
'panel' => [
'type' => GridView::TYPE_PRIMARY,
'heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-user"></i>Avg total time by modeler without handover</h3>',
],
'columns' => [
[
'attribute' => 'approvemonth',
'filter' => Html::input('string', 'approvemonth'),
],
[
'attribute' => 'team',
'filter' => Html::input('string', 'team'),
// 'group' => true,
],
[
'attribute' => 'difficulty',
'filter' => Html::input('string', 'difficulty'),
// 'group' => true,
],
[
'attribute' => 'Total',
'format' => ['decimal', 2],
],
[
'attribute' => 'Avg',
'format' => ['decimal', 2],
],
],
]);
?>
<?php \yii\widgets\Pjax::end();?>