I have been trying to generate a paginated set of results using Yii::ArrayDataProvider without much success. My array is not from a model or from a set of database results BUT rather it is from a date range. All the answers I have seen online assume that my data or result set is from a database.
Basically, I have generated an array of calendar dates in my controller like this:
$dateArray= array("2012-11-01","2012-11-02","2012-11-03"...);
and then I used an ArrayDataProvider like this to generate a paginated result:
$dataProvider=new CArrayDataProvider($dateArray, array(
'id'=>FALSE,
'pagination'=>array(
'pageSize'=>10,
),
));
and I need to display this in my view in a tabular, paginated form like this:
<?php $dates=$dataProvider->getData(); ?>
<?php foreach($dates as $date): ?>
<?php echo '<tr>'; ?>
<?php echo '<td>$date</td>'; ?>
<?php echo '<td>Some Info</td>'; ?>
<?php echo '<td>Some info</td>'; ?>
<?php echo '<td>Some other info</td>'; ?>
<?php echo '</tr>'; ?>
And then the pagination links will be displayed at the bottom of the table like this.
<?php $this->widget('CLinkPager', array('pages' => $days->pagination)); ?>
My code only displays the first page and does not display other subsequent pages
Any help will be greatly appreciated