yii2 gridview没有分页不会超过3千条记录

时间:2017-07-08 13:58:40

标签: php jquery gridview pagination yii2

当我点击控制器的动作并禁用分页时,网页将不会加载... 问题是当我点击某种动作控制器时:

public function actionMyview(){
return $this->render("//myview/index");
}

在视图代码中我正在制作某种MVVM(我正在调用ActiveDataProvider):

<?php
set_time_limit(0);
use yii\helpers\Html;
use yii\grid\GridView;
use frontend\models\myModel;
use yii\web\View;
use yii\data\ActiveDataProvider;
$dataProvider2 = new ActiveDataProvider([
            'query' => myModel::find(),
            'pagination' => false,
        ]);

$this->title = 'Listing 3 thousand records';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="ventas-model-index">

    <h1><?= Html::encode($this->title) ?></h1>

    <p>
        <?= Html::a('Create manually a new record', ['create'], ['class' => 'btn btn-success col-xs-4 col-md-4 col-sm-4 col-lg-4']) ?>
        <div class="col-xs-3 col-md-3 col-sm-3 col-lg-3" >
    <input type="text" class="form-control" id="search-criteria" placeholder="please write a text in order to search" width=""/>

    </div>
    <span class="col-xs-5 col-md-5 col-sm-5 col-lg-5">&nbsp;</span>
        <?php

$this->registerJs("
var rows = jQuery('.table tr');
$('#search-criteria').keyup(function() {
    var val = jQuery.trim($(this).val()).replace(/ +/g, ' ').toLowerCase();
    rows.show().filter(function() {
        var text = jQuery(this).text().replace(/\s+/g, ' ').toLowerCase();
        return !~text.indexOf(val);
    }).hide();
});
",
    View::POS_END,
    'ventanamodal001');
         ?>
    </p>

    <?php echo GridView::widget([
        'dataProvider' => $dataProvider2,        
        'columns' => [
            [
                            'attribute' => 'date',
                            'format' => ['date', 'php:d/m/Y']
                        ], 
            ["label"=>'First Column',"attribute"=>"first","value"=>function($data0){
                return myModel::aBolivares($data0->first);

            }],
            ["label"=>'second Column',"attribute"=>'second',"value"=>function($data0){
                return myModel::aBolivares($data0->second);
            }],

            ["label"=>"totals","value"=>function($data0){
                $totals=$data0->first+$data0->secod;
                return myModel::aBolivares($totals);
            },"format"=>"html","enableSorting"=>true,"attribute"=>"first"],
            ['label'=>'description',
            'value'=>function ($data){                
                return empty($data->Observ)?" ":"<p class='glyphicon glyphicon-eye-open'></p>";
            },
            "format"=>"html","attribute"=>"Observ"],            
            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
</div>

代码示例将迭代到给予yii \ grid \ GridView的yii2 ActiveDataProvider对象; ...当我上传到远程位置时,它将失败:(我正在使用HostGator共享托管)。

重要的是说:直接从DB获取超过3千记录= = 3000记录时,它将失败。如果你使用让我们说1500条记录它会减速但会起作用...只有在注入大量记录时才会失败......

0 个答案:

没有答案