CListView and pager limitation

Hi to all,

I am little confused with one workaround here.

I have something like this:




	$dataProvider = $dataProvider=new CActiveDataProvider('Objects', array(

		'criteria'=>array(

                        'condition'=>"SOME CONDITION HERE",

			'order'=>' `count` DESC,

			),

		));	


//and then


$this->widget('zii.widgets.CListView', array(

    'dataProvider'=>$dataProvider,

    'itemView'=>'_view',

    'ajaxUpdate'=>false,

    'summaryText'=>false

)); 



So I must tell to pager:

  1. If there is count >= 3 -> to show only only records with count >= 3.

  2. But if count < 3 only, to show only two pages.

  3. And third condition is if count < 1 - to show only one page of records.

To summarize:

I want to avoid multiple queries (currently 3) and I just wondering is there a way the pager to do this instead or to edit $dataProvider object somehow…

Coz if I tell to condition - "and count >= 3" i miss the rest of records and need to run another query… which is really slow solution.

Thanks!

I don’t understand the problem.

The number of page depends on how many records there are and how many records will be displayed in each page.

What for do you want a different implementation depending on the count? This count is used as a condition that can vary the number of items, therefore the number of pages.

count in my case is column.

The problem is that i have for example 250 records returned, then:

  1. if i have at least one result with count >= 3 - show only these records

else

  1. if i have at least one result with count > 0 AND < 3 - show first two pages of these records

else

  1. if in result have only values in count column < 1 - show only one page from results

And that’s the problem. Because if I filter result by this:




"AND `count` >= 3"



And totalItemCount is zero -> i need another query for case 2, and maybe another one for case 3, which is veery slow solution. :)