⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Sorting in the grid



viraj

viraj
  • profile picture
  • Member

Posted 04 June 2012 - 11:32 AM

hello every one

i have integrated the grid in my project . The grid works fine and is really helpful . But there is one thing which i dont know how to handel . In my project there is an function of sorting the records once we add it in the admin pannel of the site (Eg if i add 10 news record . The admin will have the right to decide which one will appear first second and third etc ). The gcocery crud i guess does not support sorting of records . can any one help me out with it how it can be achieved by grocery crud

Thanks

fieldju

fieldju
  • profile picture
  • Member

Posted 05 June 2012 - 07:41 AM

The ordering can be done with http://www.grocerycrud.com/documentation/options_functions/order_by but this function uses data from the database to do the sorting.
so you would give a column and tell it to order_by('column', 'desc') or order_by('column', 'asc')

If you wanted to chose the order yourself would need to have an editable field in the table that would be the order_by value and it would be potentially bigO N every time you changed the order of 1 person