0

I am trying to modify a table built using Yii boostrap and CactiveDataprovider, the table works fine but it automatically also displays the count of all items found, how to disable displaying this count

this is the view logic currently

$this->widget('bootstrap.widgets.TbListView', array(
    'dataProvider'=>$dataProvider,
    'itemView'=>'_view',
    'viewData'=>array('page'=>$page),
    'itemsTagName'=>'table',
    'itemsCssClass'=>'items table table-striped table-condensed',
    'emptyText'=>'<i> Sorry, there are no active items to display</i>',
                  )); 
2

5 Answers 5

2

You need to add this line:

'template' => "{sorter}\n{items}\n{pager}",

TbListView extends from CListView, which uses the template variable to control the layout. See: http://www.yiiframework.com/doc/api/1.1/CListView#template-detail

The default template is "{summary}\n{sorter}\n{items}\n{pager}" where {summary} is what shows the count. So if you remove that, the count won't show

1
  • thanks it worked :) .. with your method i was also able to move the summary content to the footer as well.
    – Manquer
    Apr 14, 2013 at 4:29
1

You might be reffering to: example

If so, set the template property as needed.

You need to delete the summary text.

pages stands for the pagination

items stands for ... the list of items

<?php
$this->widget('zii.widgets.CListView', array(
    'dataProvider' => $dataProvider,
    'template' => "{summary}\n{pager}\n{items}\n{summary}\n{pager}",
    'itemView' => '_index',
    'pager' => array(
        'maxButtonCount' => 10,
    ),
        )
);
?>
0
1

It is easy. put propriety summaryText false.

<?php $this->widget('bootstrap.widgets.TbListView',array(
    'dataProvider'=>$dataProvider,
    'itemView'=>'_view_mercado',
    'summaryText'=>false //make it for hide summary text
)); ?> 
0

What about using CSS? is pretty straight forward

7
  • How would you to that ? do you mean by hiding the specific class ?
    – Manquer
    Apr 21, 2013 at 11:52
  • the way i did it was .list-view .summary { display:none; } use a container to make sure it only hides in the place you want it and not across all the app
    – Dvid Silva
    Apr 23, 2013 at 14:23
  • That should have work for me i guess, but isn't it a bit messy? is not better to change at the php/framework side of things rather than hiding it by CSS ?? I mean why pass data to the view if it is not going to be used at all?
    – Manquer
    Apr 23, 2013 at 18:44
  • I know, unfortunately the docs are not very clear about all the things you can do and many hacks are necessary, plus, is just a couple bites more or so, it won't affect your performance.
    – Dvid Silva
    Apr 23, 2013 at 22:16
  • Yeah, true the documentation is not quite comprehensive, and extensions are even worse :(
    – Manquer
    Apr 24, 2013 at 18:15
0

I got this alternative answer from an offline source, posting here for completeness.
Both Ionut-flavius-Pogacian and frostyterrier methods worked and are better solutions as defining the template gives even more control over the widget behavior rather than just defining the summaryText as in the answer below

Tblistview is not documented in Yii-bootstrap documentation, but scanning the source it seems it is wrapper for CListview class in Yii.

CListview extends CBaseListView which has the summaryText property. Passing Blank data to it, removes the count which is active by default.

http://www.yiiframework.com/doc/api/1.1/CBaseListView#template-detail

SummaryText has the following usable variables

{start}: the starting row number (1-based) currently being displayed 
{end}: the ending row number (1-based) currently being displayed 
{count}: the total number of rows
{page}: the page number (1-based) current being displayed, available since version 1.1.3
{pages}: the total number of pages, available since version 1.1.3 

{start} {end} and {count} are visible by default

The code could be modified to

$this->widget('bootstrap.widgets.TbListView', array(
    'dataProvider'=>$dataProvider,
    'itemView'=>'_view',
    'viewData'=>array('page'=>$page),
    'itemsTagName'=>'table',
    'itemsCssClass'=>'items table table-striped table-condensed',
    'emptyText'=>'<i> Sorry, there are no active items to display</i>',
    'summaryText'=>''
                  )); 

Your Answer

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

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