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 > <mathias.koell...@googlemail.com> 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 -~----------~----~----~----~------~----~------~--~---