Don't render summary on gridviews?

How to avoid the COUNT sql statement generated by CGridView and not to render Summary (the section with text "Displaying xxx of xxx result(s).")?

It’s possible to change the summary text.

See CBaseListView::summaryText

As for the COUNT sql statement, I think it will be executed regardless of the summary text, because the pagination will need the row count.

For anyone who was wondering:

$this->widget(‘zii.widgets.grid.CGridView’, array(

    'id'=>'client-donations-grid',


    [b]'summaryText'=>'',[/b]


     'pager'=>array(


        'header'=>'',


        'firstPageLabel'=>'<<',


        'prevPageLabel'=>'<',


        'nextPageLabel'=>'>',


        'lastPageLabel'=>'>>',


         


    ),


    


    'dataProvider'=>new CArrayDataProvider($model->donations, 


            array(


                'sort'=>$sort,


                'pagination'=>array(


                    'pageSize'=>3,


                ),


            )),


    'columns'=>array(


            array(


            'name'=>'charity_year_id',

Thanks.

The summary can be moved or excluded by defining template explicitly.

/Tommy

I tend to use the template property to achieve this. You can use skins to apply this at a global level across all your widgets. Or you can subclass the grid view and redefine the template property in there but that’s normally only if you need to change behaviour.

I agree with the previous two replies. Using the template variable is much better. Here is an example of how you can form the template variable using ob. This example was taken from CListView but it is much the same:




ob_start(); ?>

//        {summary}  //Omitted to stop summary from showing

	{pager}

	{sorter}


	<table class="list_sub_objects_in_series" style='width:100%;' cellspacing="0" cellpadding="0"><thead>

		<tr>

		        <th>Tefno</th>

			<th>Title</th>

			<th>sub title</th>

			<th>Grade</th>

			<th>Volume</th>

			<th>Shown on website</th>

		</tr>

		</thead><tbody>{items}</tbody></table>

	<?php

	$list_template = ob_get_contents();

ob_end_clean();



It’s pitty that only solution is editing template. It would be much better to add “enableSummary” property to CGridview

CGridView template is a simple attribute with default value:




public $template="{summary}\n{items}\n{pager}";



so changing it is not such great challenge…