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.
–All–
Vendor 1
Vendor 2
…
<% selection :product, :in_use, [[’–All–’,‘all’],[‘YES’,
‘true’],[‘NO’, ‘false’]] %>
will generate a list of ‘All’, ‘YES’, ‘NO’
–All–
YES
NO
- 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. - How do I use ajax to sort without postback?
- 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 