Yii Framework Forum: Problem with CLinkPager - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Problem with CLinkPager Rate Topic: -----

#1 User is offline   natebrp 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 22-May 12

Posted 28 June 2012 - 10:12 AM

Hi All,

I am having difficulty getting my CLinkPager to properly paginate my list. Instead of splitting my items into multiple pages it just puts them all onto one page. It seems to be able to tell how many pages it needs because it puts the right number of pages in the pager at the bottom but all the items end up on the first page.

My Controller Code:

...
 $pins = $pinCollection->findAll();
			
			
            $criteria = $pinCollection->getDbCriteria();
			
			if($criteria){
				error_log(json_encode($criteria));
			}
			
			$item_count = count($pins);
	        //$item_count = count(Pin::model()->count($criteria));
			
	                
	        $pages = new CPagination($item_count);
	      	    
	        $pages->setPageSize(20);
	        $pages->applyLimit($criteria);  // the trick is here!
	        
	        $this->render('list',array(
	                'pins' => $pins,
	               'item_count'=>$item_count,
	                'page_size'=>50,
	                
	                'pages'=>$pages,
	        ));



$pins is the whole list of items that I want to display

My View Code:

<?php if ($pins): ?>

    <table id="pinsDataGrid">
        <?php foreach ($pins as $_pin): ?>
        <tr>
            <td width="23">
                <?php
                echo CHtml::image(Yii::app()->baseUrl . '/images/arrow.png', 'Drag to a folder or category', array(
                    'class' => 'draglist',
                    'title' => 'Drag to a folder or category',
                ));
                ?>
               ETC..........
        </tr>
        <?php endforeach; ?>
    </table>
    
    <?php
    $this->widget('CLinkPager', array(
            'currentPage'=>$pages->getCurrentPage(),
            'itemCount'=>$item_count,
            'pageSize'=>$page_size,
            'maxButtonCount'=>5,
            //'nextPageLabel'=>'My text >',
            'header'=>'',
        
        ));

?>
        
   
    
<?php endif; ?>



Thanks in advance
0

#2 User is offline   warmoger 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 32
  • Joined: 06-January 11

Posted 28 June 2012 - 10:26 AM

//$item_count = count($pins);
$item_count = count(Pin::model()->count($criteria));


Work?
0

#3 User is offline   natebrp 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 22-May 12

Posted 28 June 2012 - 10:31 AM

View Postwarmoger, on 28 June 2012 - 10:26 AM, said:

//$item_count = count($pins);
$item_count = count(Pin::model()->count($criteria));


Work?


No, unfortunately that makes the pager think that there is only one item to put into the list and it still dumps all the items onto the first page but it does not display the pager at the bottom.
0

#4 User is offline   natebrp 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 22-May 12

Posted 28 June 2012 - 12:14 PM

I am trying to use the CListPager Widget inside of another widget. Could that cause an issue?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users