I know how the paginator works and how I can define my conditions to
filter as I like, but I was wondering how to add some more usability
to this so let's say the user should set the filters "on the fly" with
some drop downs...
So I made some dropdowns with some options such as order => ASC/DESC,
limit => 5,10,20,50 and oderby => lastname/firstname/email...
That's really easy I think, so I created this as a form on top of the
index-table, and checked in my controller wether the form is sent or
not.
The options I selected with my dropdowns are set and when I see the
pagination after I hit "Sent!" the table is sorted as I selected it.
But now comes the problem:
After I hit "Page 2", my filters are overwritten by the default values
of my controller. So I think I'm doing something wrong, and I need a
simple example of how I can achieve the desired functionality.
Could please someone give me a hint how I can do it? When I hit the
page-change link, my selected values are overwritten beause the
RequestHandler does not kick in.
Here's my controller-code:
public function myProfs() {
$limit = 10;
$order = 'ASC';
$sortby = 'lastname';
if($this->RequestHandler->IsPost()) {
$limit = $this->data['Professor']['limit'];
$order = $this->data['Professor']['order'];
$sortby = $this->data['Professor']['sortby'];
}
$this->paginate['Professor'] = array(
'contain' => false,
'conditions' => array(
'Professor.deleted' => 0,
'Professor.user_id' => $this->Auth->User('id')
),
'limit' => $limit,
'order' => array(
'Professor.'.$sortby => $order
)
);
$limits = $this->Professor->getItemCount();
$orders = $this->Professor->order();
$sortbies = $this->Professor->sortBy();
$professors = $this->paginate('Professor');
$this->set(compact('professors', 'limits', 'orders',
'sortbies'));
}
Regards,
DD
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment