Re: sorting records based on combobox selection

2008-12-09 Thread [EMAIL PROTECTED]

It may not look pretty but why not use a simple "table" of allowed
order values?
var $order_options = array(
  array('Alert.created'=>'DESC'),
  array('Alert.created'=>'ASC'),
...
);

You can inset the right one using: $order_options
[$value_from_combo_box]

There is of-course also the option of reordering the data using
Javascript but I would only consider this for very limited datasets
that do not need paging (or limited enough to be paged using
Javascript) in an interface that was already heavily Javascript
dependent. For a simple standard web-page reloading from the server is
the common approach.

/Martin


On Dec 10, 7:27 am, Sami <[EMAIL PROTECTED]> wrote:
> hi,
>   i have to change paginate order query based on user selection on
> combo box, How to solve? .This my coding...
> In controller,
>      ...
>         var $paginate=array('limit'=>10,'page'=>1,'order'=>array
> ('Alert.created'=>'DESC'));
>         function index() {
>                  $this->Alert->recursive = 0;
>                  $this->set('alerts', $this->paginate());
>          }.
> In index.ctp :
> ...
> select  id='order' onchange='...' >
> Sort by Date Descending
> Sort by Date Ascending
> Sort by Category/Date Descending
> Sort by Title/Date Descending
> 
> 
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



sorting records based on combobox selection

2008-12-09 Thread Sami

hi,
  i have to change paginate order query based on user selection on
combo box, How to solve? .This my coding...
In controller,
 ...
var $paginate=array('limit'=>10,'page'=>1,'order'=>array
('Alert.created'=>'DESC'));
function index() {
 $this->Alert->recursive = 0;
 $this->set('alerts', $this->paginate());
 }.
In index.ctp :
...
select  id='order' onchange='...' >
Sort by Date Descending
Sort by Date Ascending
Sort by Category/Date Descending
Sort by Title/Date Descending


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---