Skip to content
bigfleet edited this page Sep 12, 2010 · 5 revisions

form_options   = {:form => {:id => "hottest_cars_form"}}
select_options = {:select => {:class => 'filter'}}
html_options   = {:html => form_options.merge(select_options)}
url_options    = {:url => {:controller => "cars", :action => "best_sellers"}}
remote_options = {:remote => {:update => 'hotBox', :complete => "new QuoteLoader();"}}
other_options  = {:with => [:tab] }
all_options = [html_options, url_options, remote_options, other_options].inject({}){|hsh, acc| acc = acc.merge(hsh)}

Use that sort of block to set up all the options that you’d like to use and then

To Filter


<%= filter_for(:cars, all_options) %>

will work for the filtering.

I’d like the filtering to move to the Erb model of form construction rather than builder. I just don’t think it’s as elegant, and I know that it is not as flexible.

I’d also like to add support for skinning in erb, or whatever language you might have in mind.
h2. To Sort


            <% sort_header(:cars, all_options) do |sort| %>
                <%= sort.column "make"%>
                <%= sort.column "year" %>
                <%= sort.column "price_in_cents", :caption => "Price" %>
            <% end %>

That’ll generate the kind of sort block that you’re looking for, with the right links, images, AJAX callbacks, etc.

I’d also like to add support for skinning in erb, or whatever language you might have in mind.
h2. To Paginate


<%= pagination_for( @cars, :cars, {:renderer => "CustomLinkRenderer"} )%>

This gets you paginating, and you can even roll your own LinkRenderer. You’ll need to inherit from DataTable::LinkRenderer if you want to try that maneuver though.

The LinkRenderer flexibility is sufficient in terms of content generation.

Clone this wiki locally