hi, i''ve been hanging out on #rubyonrails lately (thanks for all the help guys!) and have been directed to http://rafb.net/paste/results.html a few times. On the site, I quite like the way you can click the column headings and have the list sorted. Click once, sort on a column; click again sort in reverse. Is there a preferred Ruby Way of implementing this in Rails? I would imagine the heading link would, like rafb.net, include parameters for the sort (i.e. sortby=blah&order=asc). However I can''t quite wrap my brain around how you would tell the controller the state of the template, so that the proper sort can be done. For example, say I navigate to http://site/blahblah/list?sortby=blah&order=desc. When the page is rendered, how will it know to make the ''blah'' column link http://site/blahblah/list?sortby=blah&order=asc so that the sort can be reversed? Thanks for any insights!
On 5/16/05, lester <dumpingrounds-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Is there a preferred Ruby Way of implementing this in Rails? I would imagine > the heading link would, like rafb.net, include parameters for the sort (i.e. > sortby=blah&order=asc). However I can''t quite wrap my brain around how you > would tell the controller the state of the template, so that the proper sort can > be done.Check out either "Sort Helper" or "Sort Helper2" from this page in the Rails wiki: http://wiki.rubyonrails.com/rails/show/3rd+Party+Helpers -- Regards, John Wilger ----------- Alice came to a fork in the road. "Which road do I take?" she asked. "Where do you want to go?" responded the Cheshire cat. "I don''t know," Alice answered. "Then," said the cat, "it doesn''t matter." - Lewis Carrol, Alice in Wonderland
There is a third take which I''ve been meaning to put on the wiki apart from the two mentioned (using SQL or Ruby for sorting) and that is to do all the sorting in Javascript itself - Stuart Langridge came up with a Javascript library for just that purpose - more info here: http://www.kryogenix.org/code/browser/sorttable/ No Ruby, no SQL, no page submits and no Ajax! On 5/16/05, John Wilger <johnwilger-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 5/16/05, lester <dumpingrounds-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Is there a preferred Ruby Way of implementing this in Rails? I would imagine > > the heading link would, like rafb.net, include parameters for the sort (i.e. > > sortby=blah&order=asc). However I can''t quite wrap my brain around how you > > would tell the controller the state of the template, so that the proper sort can > > be done. > > Check out either "Sort Helper" or "Sort Helper2" from this page in the > Rails wiki: http://wiki.rubyonrails.com/rails/show/3rd+Party+Helpers > -- > Regards, > John Wilger >-- sam http://www.magpiebrain.com/
That sounds really cool but it didn''t work in Safari. It seemed to reorder the columns, but they were not sorted properly. Anybody else see this problem? On 5/17/05, Sam Newman <sam.newman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> There is a third take which I''ve been meaning to put on the wiki apart > from the two mentioned (using SQL or Ruby for sorting) and that is to > do all the sorting in Javascript itself - Stuart Langridge came up > with a Javascript library for just that purpose - more info here: > http://www.kryogenix.org/code/browser/sorttable/ > > No Ruby, no SQL, no page submits and no Ajax! > > On 5/16/05, John Wilger <johnwilger-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On 5/16/05, lester <dumpingrounds-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Is there a preferred Ruby Way of implementing this in Rails? I would imagine > > > the heading link would, like rafb.net, include parameters for the sort (i.e. > > > sortby=blah&order=asc). However I can''t quite wrap my brain around how you > > > would tell the controller the state of the template, so that the proper sort can > > > be done. > > > > Check out either "Sort Helper" or "Sort Helper2" from this page in the > > Rails wiki: http://wiki.rubyonrails.com/rails/show/3rd+Party+Helpers > > -- > > Regards, > > John Wilger > > > > -- > sam > http://www.magpiebrain.com/ > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >