Hello - In my app I''m displaying many data grids, and I''m
trying to add
multiple selection lists and a search box to each grid to allow
filtering the rows. Since I''m very new to this, I''m trying to
understand
how to do things right from the start. Say I have product and vendor
models like so:
./script/generate model Product name:string, vendor_id:integer,
in_stock:boolean
./script/generate model Vendor name:string, location:string
of course, the product belongs_to :vendor and the vendor has_many
:products. So far so good.
My app displays a grid of products, and I''d like to stack filter them
using a selection list of vendors, and a list of in_stock. My first
question is how to filter the grid with each selection. Say these are
the drop down lists:
<% selection :product, :vendor_id, (Vendor.find(:all, :order =>
"name").collect {|v| [v.name, v.id] }).insert(0,
[''--All--'',''all'']) %>
# will generate a list of ''All'', ''Vendor 1'',
''Vendor 2'', etc.
# <select id="product_vendor_id"
name="product[vendor_id]">
# <option value="all">--All--</option>
# <option value="1">Vendor 1</option>
# <option value="2">Vendor 2</option>
# ...
# </select>
<% selection :product, :in_use,
[[''--All--'',''all''],[''YES'',
''true''],[''NO'', ''false'']]
%>
# will generate a list of ''All'', ''YES'',
''NO''
# <select id="product_in_stock"
name="product[in_stock]">
# <option value="all">--All--</option>
# <option value="true">YES</option>
# <option value="false">NO</option>
# </select>
1. How do I sort the table when the user selects something? I''m
assuming
this should be done with a call to the controller or helper, but not
sure how.
2. How do I use ajax to sort without postback?
3. How do I throw in a free text search box in the mix?
I realize that''s a lot of ground to cover, but even a some helpful link
will be great - thanks :)
--
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?hl=en
-~----------~----~----~----~------~----~------~--~---