Re: How to paginate with user-selected filter-options?

2009-11-29 Thread Dave
Here is a simple pseudo code example

function myProfs($limit = 10, $sort = "asc") {
  DO SEARCH WITH FILTERS
}

now make sure to add to your $paginator variable IN YOUR VIEW
'url'=>$this->params

now when you want to add custom filters, just point the link to, for
example, controller/myProfs/20/desc

On Sun, Nov 29, 2009 at 8:48 AM, DigitalDude
wrote:

> Hey,
>
> a short and simple example would be appreciated here. Setting standard-
> options is a thing I could build in, but as I do many different
> paginates in my controller I do not like do define these standards at
> the beginning of my controller so I do it in the action where it's
> needed.
>
> How does it work with GET and the url-parameter?
>
> Regards,
>
> DD
>
>
>
> On 28 Nov., 20:44, Dave  wrote:
> > You don't need to set the defaults at all in the method, these should be
> set
> > in your $paginate variable at the top of your controller.
> >
> > If you send the filter options as GET variables (or parameters for the
> > action), then you can add 'url'=>$this->params to your $paginator
> variable
> > in the view file.  This will tell the paginator to pass any custom
> > parameters along when it paginates.
> >
> > On Sat, Nov 28, 2009 at 2:30 PM, Dave  wrote:
> > > I had the same problem and used the same method. Save to session and
> check
> > > session. Also not sure if this is the best way but it works.
> >
> > > -----Original Message-
> > > From: DigitalDude [mailto:e.blumsten...@googlemail.com]
> > > Sent: November-28-09 3:40 PM
> > > To: CakePHP
> > > Subject: Re: How to paginate with user-selected filter-options?
> >
> > > Hey,
> >
> > > ok I found a way to do this, but I'm not sure if that's the right
> approach.
> >
> > > What I'm doing now, is store the incoming filter-options in the
> Session.
> > > When a user comes into the controller for the first time, I check if
> the
> > > session-keys are set, and if not, I apply some standard options. When
> the
> > > user sends the form, I write the selections into the session, and then
> set
> > > my variables with these session values. This works perfectly, even when
> I'm
> > > on page 2 and use the column-sorting everything is displayed correctly.
> >
> > > I don't know if this is absolutely correct, but it works and I'll
> further
> > > develop this if anyone can tell me a better way to do this...
> >
> > > Regards,
> >
> > > DD
> >
> > > On 28 Nov., 19:42, DigitalDude  wrote:
> > > > Hey,
> >
> > > > I tried, but it won't work. The variables für limit, order and sortby
> > > > are overwritten after I change the page of the pagination, because
> the
> > > > date from the forms no longer exist and are overwritten by my
> standard
> > > > values.
> >
> > > > The problem is that when I use my filter-form and send the form, the
> > > > variables are set. But when the paginator-link is clickes, the
> > > > controller is called again, variables are set and the RequestHandler
> > > > part will be ignored because in this case the data from the forms is
> > > > not given to the controller.
> >
> > > > So I guess I need a way to
> >
> > > > a) store the given form data (filter options) persistent in my app so
> > > > it won't be overwritten after a page-change
> >
> > > > or
> >
> > > > b) manipulate the links of the form helper after sending the form so
> > > > it will have the desired options I selected in my form...
> >
> > > > There has to be someone who already did this in an app, right?
> >
> > > > On 28 Nov., 19:33, Dave  wrote:
> >
> > > > > Rather then using request handler to check for post, you can try
> > > > > just checking if the value exists, ie
> >
> > > > > if(!empty($this->data['Professor']['limit'])) $limit =
> > > > > $this->data['Professor']['limit'];
> >
> > > > > On Sat, Nov 28, 2009 at 1:16 PM, DigitalDude
> > > > > wrote:
> >
> > > > > > Hey,
> >
> > > > > > 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
> > > > > > usabilit

Re: How to paginate with user-selected filter-options?

2009-11-29 Thread DigitalDude
Hey,

a short and simple example would be appreciated here. Setting standard-
options is a thing I could build in, but as I do many different
paginates in my controller I do not like do define these standards at
the beginning of my controller so I do it in the action where it's
needed.

How does it work with GET and the url-parameter?

Regards,

DD



On 28 Nov., 20:44, Dave  wrote:
> You don't need to set the defaults at all in the method, these should be set
> in your $paginate variable at the top of your controller.
>
> If you send the filter options as GET variables (or parameters for the
> action), then you can add 'url'=>$this->params to your $paginator variable
> in the view file.  This will tell the paginator to pass any custom
> parameters along when it paginates.
>
> On Sat, Nov 28, 2009 at 2:30 PM, Dave  wrote:
> > I had the same problem and used the same method. Save to session and check
> > session. Also not sure if this is the best way but it works.
>
> > -Original Message-
> > From: DigitalDude [mailto:e.blumsten...@googlemail.com]
> > Sent: November-28-09 3:40 PM
> > To: CakePHP
> > Subject: Re: How to paginate with user-selected filter-options?
>
> > Hey,
>
> > ok I found a way to do this, but I'm not sure if that's the right approach.
>
> > What I'm doing now, is store the incoming filter-options in the Session.
> > When a user comes into the controller for the first time, I check if the
> > session-keys are set, and if not, I apply some standard options. When the
> > user sends the form, I write the selections into the session, and then set
> > my variables with these session values. This works perfectly, even when I'm
> > on page 2 and use the column-sorting everything is displayed correctly.
>
> > I don't know if this is absolutely correct, but it works and I'll further
> > develop this if anyone can tell me a better way to do this...
>
> > Regards,
>
> > DD
>
> > On 28 Nov., 19:42, DigitalDude  wrote:
> > > Hey,
>
> > > I tried, but it won't work. The variables für limit, order and sortby
> > > are overwritten after I change the page of the pagination, because the
> > > date from the forms no longer exist and are overwritten by my standard
> > > values.
>
> > > The problem is that when I use my filter-form and send the form, the
> > > variables are set. But when the paginator-link is clickes, the
> > > controller is called again, variables are set and the RequestHandler
> > > part will be ignored because in this case the data from the forms is
> > > not given to the controller.
>
> > > So I guess I need a way to
>
> > > a) store the given form data (filter options) persistent in my app so
> > > it won't be overwritten after a page-change
>
> > > or
>
> > > b) manipulate the links of the form helper after sending the form so
> > > it will have the desired options I selected in my form...
>
> > > There has to be someone who already did this in an app, right?
>
> > > On 28 Nov., 19:33, Dave  wrote:
>
> > > > Rather then using request handler to check for post, you can try
> > > > just checking if the value exists, ie
>
> > > > if(!empty($this->data['Professor']['limit'])) $limit =
> > > > $this->data['Professor']['limit'];
>
> > > > On Sat, Nov 28, 2009 at 1:16 PM, DigitalDude
> > > > wrote:
>
> > > > > Hey,
>
> > > > > 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

Re: How to paginate with user-selected filter-options?

2009-11-28 Thread Devendra
I am sure this is not the best way as it wont provide any bookmarking
facility if the user want to save or share the page as is.
You can think of using in line links for this as gmail does
#orderby_value-sort_value or make them like parameters in URL itself
/order-value/sort-value/ etc.
I don't know how exactly to do this as a beginner. Maybe an expert around
here could suggest how to achieve this.

Thank  you!

Devendra{
   cheers()
}


On Sun, Nov 29, 2009 at 1:00 AM, Dave  wrote:

> I had the same problem and used the same method. Save to session and check
> session. Also not sure if this is the best way but it works.
>
> -Original Message-
> From: DigitalDude [mailto:e.blumsten...@googlemail.com]
> Sent: November-28-09 3:40 PM
> To: CakePHP
> Subject: Re: How to paginate with user-selected filter-options?
>
> Hey,
>
> ok I found a way to do this, but I'm not sure if that's the right approach.
>
> What I'm doing now, is store the incoming filter-options in the Session.
> When a user comes into the controller for the first time, I check if the
> session-keys are set, and if not, I apply some standard options. When the
> user sends the form, I write the selections into the session, and then set
> my variables with these session values. This works perfectly, even when I'm
> on page 2 and use the column-sorting everything is displayed correctly.
>
> I don't know if this is absolutely correct, but it works and I'll further
> develop this if anyone can tell me a better way to do this...
>
> Regards,
>
> DD
>
>
>
> On 28 Nov., 19:42, DigitalDude  wrote:
> > Hey,
> >
> > I tried, but it won't work. The variables für limit, order and sortby
> > are overwritten after I change the page of the pagination, because the
> > date from the forms no longer exist and are overwritten by my standard
> > values.
> >
> > The problem is that when I use my filter-form and send the form, the
> > variables are set. But when the paginator-link is clickes, the
> > controller is called again, variables are set and the RequestHandler
> > part will be ignored because in this case the data from the forms is
> > not given to the controller.
> >
> > So I guess I need a way to
> >
> > a) store the given form data (filter options) persistent in my app so
> > it won't be overwritten after a page-change
> >
> > or
> >
> > b) manipulate the links of the form helper after sending the form so
> > it will have the desired options I selected in my form...
> >
> > There has to be someone who already did this in an app, right?
> >
> > On 28 Nov., 19:33, Dave  wrote:
> >
> > > Rather then using request handler to check for post, you can try
> > > just checking if the value exists, ie
> >
> > > if(!empty($this->data['Professor']['limit'])) $limit =
> > > $this->data['Professor']['limit'];
> >
> > > On Sat, Nov 28, 2009 at 1:16 PM, DigitalDude
> > > wrote:
> >
> > > > Hey,
> >
> > > > 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:
> >
> > > > publi

Re: How to paginate with user-selected filter-options?

2009-11-28 Thread Dave
You don't need to set the defaults at all in the method, these should be set
in your $paginate variable at the top of your controller.

If you send the filter options as GET variables (or parameters for the
action), then you can add 'url'=>$this->params to your $paginator variable
in the view file.  This will tell the paginator to pass any custom
parameters along when it paginates.

On Sat, Nov 28, 2009 at 2:30 PM, Dave  wrote:

> I had the same problem and used the same method. Save to session and check
> session. Also not sure if this is the best way but it works.
>
> -Original Message-
> From: DigitalDude [mailto:e.blumsten...@googlemail.com]
> Sent: November-28-09 3:40 PM
> To: CakePHP
> Subject: Re: How to paginate with user-selected filter-options?
>
> Hey,
>
> ok I found a way to do this, but I'm not sure if that's the right approach.
>
> What I'm doing now, is store the incoming filter-options in the Session.
> When a user comes into the controller for the first time, I check if the
> session-keys are set, and if not, I apply some standard options. When the
> user sends the form, I write the selections into the session, and then set
> my variables with these session values. This works perfectly, even when I'm
> on page 2 and use the column-sorting everything is displayed correctly.
>
> I don't know if this is absolutely correct, but it works and I'll further
> develop this if anyone can tell me a better way to do this...
>
> Regards,
>
> DD
>
>
>
> On 28 Nov., 19:42, DigitalDude  wrote:
> > Hey,
> >
> > I tried, but it won't work. The variables für limit, order and sortby
> > are overwritten after I change the page of the pagination, because the
> > date from the forms no longer exist and are overwritten by my standard
> > values.
> >
> > The problem is that when I use my filter-form and send the form, the
> > variables are set. But when the paginator-link is clickes, the
> > controller is called again, variables are set and the RequestHandler
> > part will be ignored because in this case the data from the forms is
> > not given to the controller.
> >
> > So I guess I need a way to
> >
> > a) store the given form data (filter options) persistent in my app so
> > it won't be overwritten after a page-change
> >
> > or
> >
> > b) manipulate the links of the form helper after sending the form so
> > it will have the desired options I selected in my form...
> >
> > There has to be someone who already did this in an app, right?
> >
> > On 28 Nov., 19:33, Dave  wrote:
> >
> > > Rather then using request handler to check for post, you can try
> > > just checking if the value exists, ie
> >
> > > if(!empty($this->data['Professor']['limit'])) $limit =
> > > $this->data['Professor']['limit'];
> >
> > > On Sat, Nov 28, 2009 at 1:16 PM, DigitalDude
> > > wrote:
> >
> > > > Hey,
> >
> > > > 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;
> > > &

RE: How to paginate with user-selected filter-options?

2009-11-28 Thread Dave
I had the same problem and used the same method. Save to session and check
session. Also not sure if this is the best way but it works.

-Original Message-
From: DigitalDude [mailto:e.blumsten...@googlemail.com] 
Sent: November-28-09 3:40 PM
To: CakePHP
Subject: Re: How to paginate with user-selected filter-options?

Hey,

ok I found a way to do this, but I'm not sure if that's the right approach.

What I'm doing now, is store the incoming filter-options in the Session.
When a user comes into the controller for the first time, I check if the
session-keys are set, and if not, I apply some standard options. When the
user sends the form, I write the selections into the session, and then set
my variables with these session values. This works perfectly, even when I'm
on page 2 and use the column-sorting everything is displayed correctly.

I don't know if this is absolutely correct, but it works and I'll further
develop this if anyone can tell me a better way to do this...

Regards,

DD



On 28 Nov., 19:42, DigitalDude  wrote:
> Hey,
>
> I tried, but it won't work. The variables für limit, order and sortby 
> are overwritten after I change the page of the pagination, because the 
> date from the forms no longer exist and are overwritten by my standard 
> values.
>
> The problem is that when I use my filter-form and send the form, the 
> variables are set. But when the paginator-link is clickes, the 
> controller is called again, variables are set and the RequestHandler 
> part will be ignored because in this case the data from the forms is 
> not given to the controller.
>
> So I guess I need a way to
>
> a) store the given form data (filter options) persistent in my app so 
> it won't be overwritten after a page-change
>
> or
>
> b) manipulate the links of the form helper after sending the form so 
> it will have the desired options I selected in my form...
>
> There has to be someone who already did this in an app, right?
>
> On 28 Nov., 19:33, Dave  wrote:
>
> > Rather then using request handler to check for post, you can try 
> > just checking if the value exists, ie
>
> > if(!empty($this->data['Professor']['limit'])) $limit = 
> > $this->data['Professor']['limit'];
>
> > On Sat, Nov 28, 2009 at 1:16 PM, DigitalDude
> > wrote:
>
> > > Hey,
>
> > > 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,
> > > 

Re: How to paginate with user-selected filter-options?

2009-11-28 Thread DigitalDude
Hey,

ok I found a way to do this, but I'm not sure if that's the right
approach.

What I'm doing now, is store the incoming filter-options in the
Session. When a user comes into the controller for the first time, I
check if the session-keys are set, and if not, I apply some standard
options. When the user sends the form, I write the selections into the
session, and then set my variables with these session values. This
works perfectly, even when I'm on page 2 and use the column-sorting
everything is displayed correctly.

I don't know if this is absolutely correct, but it works and I'll
further develop this if anyone can tell me a better way to do this...

Regards,

DD



On 28 Nov., 19:42, DigitalDude  wrote:
> Hey,
>
> I tried, but it won't work. The variables für limit, order and sortby
> are overwritten after I change the page of the pagination, because the
> date from the forms no longer exist and are overwritten by my standard
> values.
>
> The problem is that when I use my filter-form and send the form, the
> variables are set. But when the paginator-link is clickes, the
> controller is called again, variables are set and the RequestHandler
> part will be ignored because in this case the data from the forms is
> not given to the controller.
>
> So I guess I need a way to
>
> a) store the given form data (filter options) persistent in my app so
> it won't be overwritten after a page-change
>
> or
>
> b) manipulate the links of the form helper after sending the form so
> it will have the desired options I selected in my form...
>
> There has to be someone who already did this in an app, right?
>
> On 28 Nov., 19:33, Dave  wrote:
>
> > Rather then using request handler to check for post, you can try just
> > checking if the value exists, ie
>
> > if(!empty($this->data['Professor']['limit'])) $limit =
> > $this->data['Professor']['limit'];
>
> > On Sat, Nov 28, 2009 at 1:16 PM, DigitalDude
> > wrote:
>
> > > Hey,
>
> > > 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 sitehttp://cakeqs.organdhelp 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+unsubscr...@googlegroups.comFor
> > >  more options, visit this group at
> > >http://groups.google.com/group/cake-php?hl=en

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

Re: How to paginate with user-selected filter-options?

2009-11-28 Thread DigitalDude
Hey,

I tried, but it won't work. The variables für limit, order and sortby
are overwritten after I change the page of the pagination, because the
date from the forms no longer exist and are overwritten by my standard
values.

The problem is that when I use my filter-form and send the form, the
variables are set. But when the paginator-link is clickes, the
controller is called again, variables are set and the RequestHandler
part will be ignored because in this case the data from the forms is
not given to the controller.

So I guess I need a way to

a) store the given form data (filter options) persistent in my app so
it won't be overwritten after a page-change

or

b) manipulate the links of the form helper after sending the form so
it will have the desired options I selected in my form...

There has to be someone who already did this in an app, right?




On 28 Nov., 19:33, Dave  wrote:
> Rather then using request handler to check for post, you can try just
> checking if the value exists, ie
>
> if(!empty($this->data['Professor']['limit'])) $limit =
> $this->data['Professor']['limit'];
>
> On Sat, Nov 28, 2009 at 1:16 PM, DigitalDude
> wrote:
>
> > Hey,
>
> > 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 sitehttp://cakeqs.organd 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+unsubscr...@googlegroups.comFor
> >  more options, visit this group at
> >http://groups.google.com/group/cake-php?hl=en

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: How to paginate with user-selected filter-options?

2009-11-28 Thread Dave
Rather then using request handler to check for post, you can try just
checking if the value exists, ie

if(!empty($this->data['Professor']['limit'])) $limit =
$this->data['Professor']['limit'];



On Sat, Nov 28, 2009 at 1:16 PM, DigitalDude
wrote:

> Hey,
>
> 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+unsubscr...@googlegroups.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


How to paginate with user-selected filter-options?

2009-11-28 Thread DigitalDude
Hey,

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en