7 Replies Latest reply on Jul 7, 2013 10:50 PM by Mark Nongkhlaw

    Pagination and Sorting Issues

    Val Palhories

      I have an item list that I return thru a <listview> for the operator to select. Since the list can be rather large, I implemented pagination which works great. The issue that I'm having is related to sorting. When more than one page of results are returned, sorting sorts only the items on the current page and if you go to the next page of results, it is no longer sorted.  (for example, when sorting by a date). If I sort the list in descending order, then it works just fine.

       

      Here's a snippet of my code from the controller:

       

      return Item.paginate(

                        :page => page,

                        :per_page => pageCount,

                        :conditions => [

                        "ItemNumber like ? OR Description like ?",

                         "'%" + searchCriteria + "%'",

                         "'%" + searchCriteria + "%'"

                        ],:order => "ItemNumber"   

          )

       

      I'm sure it's something stupid but I can't seem to figure it out!

       

      Thanks.

       

      --- Val