Hi, Is it true to say there''s no support for sorting table via clicking on column headers within the base rails download? From what I can tell pagination is included, but for sorting you need to following the "Sort Helper" topic in the wiki at: http://wiki.rubyonrails.com/rails/pages/Sort+Helper Tks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Yeah, there''s nothing built-in. But take a look at the code for the sorting_helper, it''s only 20-25 lines of code for a general purpose sorter. It goes to show how easy this sort of thing is to accomplish in Rails. I would probably never bother with this sorter code since it''s trivially fast to implement exactly what I want. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Tks Gabriel - you don''t have a site I can have a look at? - I''d be interested in seeing how people have laid-out their sorting links --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Greg H wrote:> Tks Gabriel - you don''t have a site I can have a look at? - I''d be > interested in seeing how people have laid-out their sorting linksI use sort_helper - www.crmonrails.com - go to the leads or orders list and click on any of the column headers. Don''t have it on the activities list. Not much data in that demo app, but it will give you an idea of how I did it. Michael -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
got it Michael thanks - cool - what did you use on the site for the "page forward" / "jump to last page"? Was it the rails paging mechanism? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Greg H wrote:> got it Michael thanks - cool - what did you use on the site for the > "page > forward" / "jump to last page"? Was it the rails paging mechanism?Here is the code that I put in the application helper file (application_helper.rb) for the sort colums and for the pagination that you ask about. I don''t pretend to be an optimization guru - so I''m sure there is a better way to achieve this. However, this did the trick for me and is reused across my views. Regards, Michael #LIST VIEW SORT def list_view_td_sort_column(column_name, display_value) list_text <<-EOL <td WIDTH="1" class="blackLine" NOWRAP><img src="/images/blank.gif"></td> EOL list_text = list_text + sort_header_tag(column_name, :title => display_value) end #NAVIGATION/PAGINATION HELPER def list_view_paginate(page_object) return_html <<-EOL <tr height="20"> <td COLSPAN="30" class="listFormHeaderLinks"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td> Showing #{ page_object.current.first_item } - #{ page_object.current.last_item } of #{ page_object.item_count }</td> <td align="right"> EOL if page_object.current.first? then return_html = return_html + <<-EOL <img src="/images/start_disabled.gif" border="0" align="absmiddle"> <img src="/images/previous_disabled.gif" border="0" align="absmiddle"> EOL else return_html = return_html + <<-EOL #{ link_to(image_tag("start.gif", :border => 0, :align => "absmiddle"), { :page => page_object.first_page }) if page_object.current.previous } #{ link_to(image_tag("previous.gif", :border => 0, :align => "absmiddle"), { :page => page_object.current.previous }) if page_object.current.previous } EOL end if page_object.current.last? then return_html = return_html + <<-EOL <img src="/images/next_disabled.gif" border="0" align="absmiddle"> <img src="/images/end_disabled.gif" border="0" align="absmiddle"> EOL else return_html = return_html + <<-EOL #{ link_to(image_tag("next.gif", :border => 0, :align => "absmiddle"), { :page => page_object.current.next }) if page_object.current.next } #{ link_to(image_tag("end.gif", :border => 0, :align => "absmiddle"), { :page => page_object.last }) if page_object.current.next } EOL end return_html = return_html + <<-EOL </td> </tr> </table> </td> </tr> EOL end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
I''m sorry - forgot to answer your question: Yes, it is using the Rails pagination object which, if you read other posts, may not be the wisest thing to do (performance)! :-) I don''t plan on having millions of rows so it will be fine for me (I think) and I strongly suspect that by the time it becomes an issue then the core guys will have figured out how to keep pagination and make it perf friendly. If they don''t then by the time I have millions of rows I''ll also have other resources available to help figure it out! :-) I hope this has been helpful to you in some way. Michael -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
thanks Michael - I''ll digest it over the next day or two :) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
if you''re ever looking to use ajax to do table sorting there''s a few resources that i''ve picked up over the last few months. This first one is just a tutorial that walks through building your own helpers for it. pretty sure it degrades well if the user doesn''t have javascript too, so it''ll prlly be easy to figure out either way. http://dev.nozav.org/rails_ajax_table.html I haven''t actually used this next one in my projects, but it looks really nice. I''ve played around with it some and it seems like it requires a little bit more of a learning curve to actually have it do just what I want. But maybe it can help you. http://www.ajaxscaffold.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
I think I found a bug in Sort Helper at http://wiki.rubyonrails.com/rails/pages/Sort+Helper I posted a note on the wiki: ====================================I think I found a bug in the code. The line: { :params => { ''sort'' => column, ''order'' => order }.merge(params) } This is trying to do a "new.merge(old)" however it seems that the merge works the other way round in terms of ensuring that the new settings override the old. I tried the following and it seemed to work: { :params => params.merge({ ''sort'' => column, ''order'' => order }) } ==================================== --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---