GSTAR  
            (Omzy83)
           
           
          
              
                January 11, 2010, 11:08am
               
               
          1 
           
         
        
          On my page I run 3 different queries:
const PAGE_SIZE=10;
$pages1=new CPagination(Application::model()->count($criteria1));
$pages1->pageSize=self::PAGE_SIZE;
$pages1->applyLimit($criteria1);
 
I also have the same code for the other two queries (using $pages2, $pages3 and $criteria2, $criteria3).
I want all 3 queries to each have a pageSize of 10. It seems at the moment that the const PAGE_SIZE is being shared by all 3 queries.
I tried hardcoding the pageSize value on all 3 queries but that did not work either.
         
         
           
        
            
            
            
         
         
             
             
          
       
      
        
        
          
On my page I run 3 different queries:
const PAGE_SIZE=10;
$pages1=new CPagination(Application::model()->count($criteria1));
$pages1->pageSize=self::PAGE_SIZE;
$pages1->applyLimit($criteria1);
 
I also have the same code for the other two queries (using $pages2, $pages3 and $criteria2, $criteria3).
I want all 3 queries to each have a pageSize of 10. It seems at the moment that the const PAGE_SIZE is being shared by all 3 queries.
I tried hardcoding the pageSize value on all 3 queries but that did not work either.
 
 
please, put the code (controller and view)
         
         
        
            
            
            
         
         
             
             
          
       
      
        
          
          
            GSTAR  
            (Omzy83)
           
           
          
              
                January 11, 2010,  3:27pm
               
               
          3 
           
         
        
          Controller:
public function actionAdmin()
{
	$criteria1=new CDbCriteria;
	$criteria1->addCondition("case_assigned_to = ''");
	
	$pages1=new CPagination(Application::model()->count($criteria1));
	$pages1->pageSize=self::PAGE_SIZE;
	$pages1->applyLimit($criteria1);
	
	$total1=$pages1->itemCount;
	$sort1=new CSort('Application');
	$sort1->applyOrder($criteria1);
	
	$models1=Application::model()->with('app_date')->findAll($criteria1);
	
	$criteria2=new CDbCriteria;
	$criteria2->addCondition("case_assigned_to != ''");
	
	$pages2=new CPagination(Application::model()->count($criteria2));
	$pages2->pageSize=self::PAGE_SIZE;
	$pages2->applyLimit($criteria2);
	$total2=$pages2->itemCount;
	$sort2=new CSort('Application');
	$sort2->applyOrder($criteria2);
	
	$models2=Application::model()->with('username', 'app_status', 'app_date')->findAll($criteria2);
	
	$criteria3=new CDbCriteria;
	$criteria3->addCondition("application_status = '009'");
	
	$pages3=new CPagination(Application::model()->count($criteria3));
	$pages3->pageSize=self::PAGE_SIZE;
	$pages3->applyLimit($criteria3);
	$total3=$pages3->itemCount;
	$sort3=new CSort('Application');
	$sort3->applyOrder($criteria3);
	
	$models3=Application::model()->findAll($criteria3);
	
	$this->render('admin', array(
		'models1'=>$models1,
		'pages1'=>$pages1,
		'total1'=>$total1,
		'sort1'=>$sort1,
		'models2'=>$models2,
		'pages2'=>$pages2,
		'total2'=>$total2,
		'sort2'=>$sort2,
		'models3'=>$models3,
		'pages3'=>$pages3,
		'total3'=>$total3,
		'sort3'=>$sort3,
	));
}
 
View:
<?php if($total1 !=0) { ?>
<table class="dataGrid">
  <thead>
  <tr>
    <th><?php echo $sort1->link('id'); ?></th>
    <th><?php echo $sort1->link('organisation_name'); ?></th>
	<th><?php echo $sort1->link('application_date'); ?></th>
	<th>Assign To</th>
	<th>Actions</th>
  </tr>
  </thead>
  <tbody>
<?php foreach($models1 as $n=>$model): ?>
  <tr class="<?php echo $n%2 ? 'even' : 'odd'; ?>">
    <td><?php echo CHtml::link($model->id, array('show', 'id'=>$model->id)); ?></td>
    <td><?php echo CHtml::encode($model->organisation_name); ?></td>
	<td><?php echo CHtml::encode($model->app_date->action_date); ?></td>
    <td>
		<?php echo CHtml::beginForm(); ?>
		<?php echo CHtml::dropDownList('Application[case_assigned_to]', '', User::model()->getUsers(), array('prompt'=>'')); ?>
		<?php echo CHtml::hiddenField('Application[app_id]', $model->id); ?>
		<?php echo CHtml::submitButton('Go'); ?>
		<?php echo CHtml::endForm(); ?>
	</td>
	<td>
      <?php echo CHtml::link('Edit', array('update', 'id'=>$model->id)); ?> | 
      <?php echo CHtml::linkButton('Delete', array(
      	  'submit'=>'',
      	  'params'=>array('command'=>'delete', 'id'=>$model->id),
      	  'confirm'=>"Are you sure to delete #{$model->id}?")); ?>
	</td>
  </tr>
<?php endforeach; ?>
  </tbody>
</table>
<br/>
<?php $this->widget('CLinkPager', array('pages'=>$pages1)); ?>
<?php } ?>
 
         
         
        
            
            
            
         
         
             
             
          
       
      
        
          
          
            GSTAR  
            (Omzy83)
           
           
          
              
                January 11, 2010,  3:32pm
               
               
          4 
           
         
        
          Can you also analyze my controller code and let me know if there any simpler ways of doing it.
         
         
        
            
            
            
         
         
             
             
          
       
      
      
        
          
          
            GSTAR  
            (Omzy83)
           
           
          
              
                January 11, 2010,  4:11pm
               
               
          6 
           
         
        
          Thanks Horacio. On that page the post by qiang says:
pageVar property: name of the GET variable storing the current page index. Defaults to ‘page’.
But I don’t have any GET variable.
         
         
        
            
            
            
         
         
             
             
          
       
      
        
        
          
 GSTAR:
 
Thanks Horacio. On that page the post by qiang says:
pageVar property: name of the GET variable storing the current page index. Defaults to ‘page’.
But I don’t have any GET variable.
 
 
I’m not sure, but try doing this
        $pages1=new CPagination(Application::model()->count($criteria1));
        $pages1->pageSize=self::PAGE_SIZE;
        $pages1->applyLimit($criteria1);
        $pages1->__set('pageVar','page1');
....
        $pages2=new CPagination.....
        $pages2->pageSize=self::PAGE_SIZE;
        $pages2->applyLimit($criteria2);
        $pages2->__set('pageVar','page2');
....
 
[edit]
http://www.yiiframework.com/doc/api/1.0.11/CComponent#__set-detail  
         
         
        
            
            
            
         
         
             
             
          
       
      
      
        
          
          
            GSTAR  
            (Omzy83)
           
           
          
              
                January 21, 2010, 11:25am
               
               
          9 
           
         
        
          Hi Horacio,
I had a look at that page you suggested above but I think that is not entirely relevant to what I’m trying to do. I don’t need to distinguish between active/inactive pagers, instead all pagers on the page need to be considered ‘active’.
         
         
        
            
            
            
         
         
             
             
          
       
      
        
          
          
            GSTAR  
            (Omzy83)
           
           
          
              
                January 22, 2010,  1:04pm
               
               
          11 
           
         
        
          How can you make sort columns unique on multiple pagers that have the same fields?