I have an index.php
file generated with the Gii Code Generator. It has a GridView with the data of a table of my database. It has 536000 rows so it moves very slow. Even sometimes exceeds 30 seconds so the page is not loaded at all.
I would like to start my index file (http://localhost:8080/persons/index.php) but with an empty GridView (or without the GridView) and it can be filled when the user uses filters of a _search.php
file.
My index.php file:
<? Pjax::begin() ?>
<? echo $this->render('_search', ['model' => $searchModel]) ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
'id',
'name',
'details',
],
]) ?>
<? Pjax::end() ?>
My _search.php file:
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
'options' => [
'data-pjax' => 1
],
]) ?>
<?= $form->field($model, 'name') ?>
<?= $form->field($model, 'datails') ?>
<div class="form-group">
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
</div>
<? ActiveForm::end() ?>
My personsController.php file:
public function actionIndex()
{
$searchModel = new PersonsSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}