11

When I use ListView I it always does a count. For example says something like:

Showing 1-1 of 1 item.

My results/items are above. How can I remove this?

Current ListView code

<?=  ListView::widget([
        'dataProvider' => $dataProvider,
        'itemOptions' => ['class' => 'col-xs-6 col-sm-3'],
        'itemView' => '_index',]);
    ?>
0

5 Answers 5

25

Found my answer used the following line:

'summary'=>'', 
2
  • 1
    you can also change the layout: 'layout' => "{pager}\n{items}\n{pager}",
    – Ruben
    Aug 5, 2015 at 9:41
  • Is query count() still executed? Nov 19, 2018 at 6:19
4

Use 'summary'=>'' in your List view

Syntax:

<?= ListView::widget([
        'dataProvider' => $dataProvider,
        'itemOptions' => ['class' => 'item'],
        'itemView' => '_step',
    'summary'=>''

    ]) ?>
3

Add the 'summary' => '' as like below in html page:

<?php

echo GridView::widget([
    'dataProvider' => $model,
    'summary' => "",
    'columns' => [
        ['class' => 'yii\grid\SerialColumn'],
        [
            'attribute' => 'name',
            'value' => function ($model) {
                return (!empty($model->name) && !empty($model->name) ) ? $model->name : 'NA';
            }
        ],
        [
            'attribute' => 'status',
            'format' => 'raw',
            'value' => function ($model) {
                return $model->getStatus();
            }
        ]
    ],
]);
?>
1

You can use emptyText too, to show your custom messages.

<?= ListView::widget([
  'dataProvider' => $dataProviderTodos,
  'pager' => [
  ],
  'options' => [
    'tag' => 'div',
    'id' => 'case-notes-wrapper',
    'class' => 'case-notes-wrapper'
  ],
  'layout' => "{items}\n{pager}",
  'itemView' => '',
  'emptyText' => '',
]); ?>

For more info, please click

1

You could also use:

'summary'=> false

I prefer false instead of empty string for better readability or in case you want to use a boolean expression (like: $row_count > 0).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.