Re: Manual sorting of data records (datasets)

2009-03-14 Thread hasentopf

Thanks for your suggestions.

I added an extra field "rank" to save the new order. Now it works
fine. Just one more thing:

 $ranks = $this->params['form']['sortable-table'];
 array_shift($ranks);

I needed to add a array_shift(), because the jQuery-Plugin delivers an
empty set at the beginning.

Have a nice weekend!
--~--~-~--~~~---~--~~
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: Manual sorting of data records (datasets)

2009-03-14 Thread hasentopf

Thanks for your suggestions.

I added an extra field "order" to save the new order. Now it works
fine.

Have a nice weekend!
--~--~-~--~~~---~--~~
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: Manual sorting of data records (datasets)

2009-03-14 Thread Adam Royle
Something like this should work (as long as you include the 
RequestHandler component). Personally, I use an extra field "rank" in my 
table which is just an integer.

if ($this->RequestHandler->isAjax() && 
!empty($this->params['form']['tableId'])) {
 foreach ($this->params['form']['tableId'] as $rank => $id) {
 $this->YourModel->save(compact('id','rank'));
 }
}

brian wrote:
> On Fri, Mar 13, 2009 at 3:50 PM, hasentopf
>   wrote:
>
>> Hi all.
>>
>> One more question:
>>
>> I tried it with the "Table Drag and Drop JQuery plugin" from
>> http://www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/
>>
>> The Plugin returns a string of the form "tableId[]=rowId1&tableId[]
>> =rowId2&tableId[]=rowId3..." via Ajax.
>>
>> I wrote an Action which receives this data. Now I need to write the
>> new order back to the database. Do you know a good cake-way-
>> possibility for updating the ids in the table?
>>
>> It must be something like "UPDATE id SET old.id=new.id" for each
>> entry, or?
>>  
>
> I would avoid changing the IDs themselves. That'll likely lead to
> *many* headaches. Better to a) have a separate column just for
> ordering or, b) use TreeBehavior. Your data isn't nested but Tree
> could still help with ordering a single level. I haven't done this but
> I don't see why it wouldn't work well.
>
> One thing though: if this data is paginated, you'll have a bit of a
> problem, as you'll only be re-ordering one "page" of the set.
>
> >
>
>

--~--~-~--~~~---~--~~
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: Manual sorting of data records (datasets)

2009-03-13 Thread brian

On Fri, Mar 13, 2009 at 3:50 PM, hasentopf
 wrote:
>
> Hi all.
>
> One more question:
>
> I tried it with the "Table Drag and Drop JQuery plugin" from
> http://www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/
>
> The Plugin returns a string of the form "tableId[]=rowId1&tableId[]
> =rowId2&tableId[]=rowId3…" via Ajax.
>
> I wrote an Action which receives this data. Now I need to write the
> new order back to the database. Do you know a good cake-way-
> possibility for updating the ids in the table?
>
> It must be something like "UPDATE id SET old.id=new.id" for each
> entry, or?

I would avoid changing the IDs themselves. That'll likely lead to
*many* headaches. Better to a) have a separate column just for
ordering or, b) use TreeBehavior. Your data isn't nested but Tree
could still help with ordering a single level. I haven't done this but
I don't see why it wouldn't work well.

One thing though: if this data is paginated, you'll have a bit of a
problem, as you'll only be re-ordering one "page" of the set.

--~--~-~--~~~---~--~~
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: Manual sorting of data records (datasets)

2009-03-13 Thread hasentopf

Hi all.

One more question:

I tried it with the "Table Drag and Drop JQuery plugin" from
http://www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/

The Plugin returns a string of the form "tableId[]=rowId1&tableId[]
=rowId2&tableId[]=rowId3…" via Ajax.

I wrote an Action which receives this data. Now I need to write the
new order back to the database. Do you know a good cake-way-
possibility for updating the ids in the table?

It must be something like "UPDATE id SET old.id=new.id" for each
entry, or?

Best Mathias
--~--~-~--~~~---~--~~
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: Manual sorting of data records (datasets)

2009-02-24 Thread Adam Royle
Both protaculous and jquery (and prob most other js libraries) have a 
sortable function so you can drag and drop records  (re-ordering) with 
your mouse, and a serialize function so you can send the re-ordered ids 
back to the server to update the database.

I'm sure you could also do the move up/down code pretty easily, but drag 
and drop is pretty common these days and is not too difficult. One thing 
to be aware, is not all libraries support sorting table rows (afaik), 
but there are workarounds.

Hope that helps,
Adam

hasentopf wrote:
> Clicking on the table header is only temporary. I need a permanent
> solution which changes the order of the table.
>
> Something like: "Move up", "Move down", "Move to the top" and "Move to
> the bottom"
>
> Best Mathias
>
> On 24 Feb., 11:51, "Liebermann, Anja Carolin"
>   wrote:
>
>> Hi Hasentopf,
>>
>> Do you think of drag and drop or sorting by clicking on the table header?
>>
>> Anja
>>
>>  
>
> >
>
>

--~--~-~--~~~---~--~~
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: Manual sorting of data records (datasets)

2009-02-24 Thread hasentopf

Clicking on the table header is only temporary. I need a permanent
solution which changes the order of the table.

Something like: "Move up", "Move down", "Move to the top" and "Move to
the bottom"

Best Mathias

On 24 Feb., 11:51, "Liebermann, Anja Carolin"
 wrote:
> Hi Hasentopf,
>
> Do you think of drag and drop or sorting by clicking on the table header?
>
> Anja
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---