I'd like to be able to display all records without the actual need of pagination but still want to keep the functionality of having sortable column headers by using something like $this->Paginator->sort()
.
Currently I'm setting 'limit' => 100
because I know I won't ever have about more than about 50 records at a time and this works just fine, however I wanted to know if there was basically a way to accomplish the sortable columns without pagination some other way such as 'limit' => unlimited
or another Component of CakePHP that would accomplish this.
Here's the Controller:
class GroupsController extends AppController {
public function view($slug = null) {
$group = $this->Group->findBySlug($slug);
$this->paginate = array(
'Person' => array(
'conditions' => array('Person.group_id' => $group["Group"]['id']),
'limit' => 100,
'recursive' => 0
)
);
$people = $this->paginate('Person');
$this->set('people', $people);
}
}
Here's the view:
<table>
<tr>
<th><?php echo $this->Paginator->sort('Person.id','Id'); ?></th>
<th><?php echo $this->Paginator->sort('first_name', 'First Name'); ?></th>
<th><?php echo $this->Paginator->sort('last_name', 'Last Name'); ?></th>
</tr>
<!-- Here is where we loop through the people -->
<?php foreach ($people as $person): ?>
<tr>
<td><?php echo $person['Person']['id']; ?></td>
<td><?php echo $person['Person']['first_name']; ?></td>
<td><?php echo $person['Person']['last_name']; ?></td>
</tr>
<?php endforeach; ?>
<?php unset($player); ?>
</table>