# AJAX drag and drop sorting with pagination

**URL:** <https://www.ruby-forum.com/t/ajax-drag-and-drop-sorting-with-pagination/94177>\
**Category:** Rails\
**Created:** [April 24, 2006, 2:40pm UTC](https://www.ruby-forum.com/t/ajax-drag-and-drop-sorting-with-pagination/94177 "2006-04-24T14:40:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stepheneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@stepheneb](https://www.ruby-forum.com/u/stepheneb)\
**Post date:** [April 24, 2006, 2:40pm UTC](https://www.ruby-forum.com/t/ajax-drag-and-drop-sorting-with-pagination/94177/1 "2006-04-24T14:40:29Z")

</div>

Drag and drop sorting is great but if you had a list of, say, 100 items,  
you’d probably want to show only 10 per page.

Has anyone seen any way to use the a drag and drop style sorting method  
over a number of pages?

I see it working by having the displayed list sortable as normal then an  
item is moved to the next page by dragging it onto the ‘next’ link…  
maybe…

Anyone got any ideas?

Steve

---

<div class="post-metadata">

**Author:** ![stepheneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@stepheneb](https://www.ruby-forum.com/u/stepheneb)\
**Post date:** [April 24, 2006, 3:21pm UTC](https://www.ruby-forum.com/t/ajax-drag-and-drop-sorting-with-pagination/94177/2 "2006-04-24T15:21:13Z")

</div>

I would question the wisdom of allowing/forcing your users to manually  
sort a list that long. It seems like a poor choice from a user  
interface perspective.

On Monday, April 24, 2006, at 1:37 PM, Stephen B. wrote:

> Anyone got any ideas?
> 
> Steve
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

\_Kevin

---

<div class="post-metadata">

**Author:** ![stepheneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@stepheneb](https://www.ruby-forum.com/u/stepheneb)\
**Post date:** [April 24, 2006, 3:27pm UTC](https://www.ruby-forum.com/t/ajax-drag-and-drop-sorting-with-pagination/94177/3 "2006-04-24T15:27:26Z")

</div>

Interesting point - but in applications i’ve previously developed,  
clients have always wanted the ability to choose which order items  
appear in - they could be pages, products, categories etc. and these can  
go into the hundreds.

In the past i’ve just had a ‘list weight’ field that you can edit via  
the list, putting in a higher number to move the item up. This is  
obviously pretty cumbersome.

My idea was that if a client wanted to move a product in relation to  
others, a drag and drop list would be suitable. However, i’d be  
interested to hear any other solutions people have to this problem.

Cheers,

Steve

---

<div class="post-metadata">

**Author:** ![stepheneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@stepheneb](https://www.ruby-forum.com/u/stepheneb)\
**Post date:** [April 24, 2006, 6:52pm UTC](https://www.ruby-forum.com/t/ajax-drag-and-drop-sorting-with-pagination/94177/4 "2006-04-24T18:52:06Z")

</div>

This actually isn’t all that hard to do. Your AJAX request only hands  
back whats on the page, so if you only show 10 items out of a hundred,  
thats all your request will get. Its just a matter of then loading up  
those items and sorting them through which ever algorithim you want.

Mine isn’t particularly speedy at the moment, but then again, people  
or only sorting things 10 at a time. 🙂

And like you said, the main use for this is simply items in relation  
to the ones around each other, so a massive sort of all 100s of items  
is never needed.

-Nick
