leikind / wice_grid

A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters
MIT License
537 stars 215 forks source link

Custom Filter for "Status" attribute... #215

Closed ddpdevang closed 9 years ago

ddpdevang commented 9 years ago

I have the status vals stored in database as integer vals, like below:

@statusVals = {"New" => 1, "Paid" => 2, "Cancelled" => 3 }
@statusValsMap = {1 => "New", 2 => "Paid", 3=> "Cancelled" }

So what I want to do is have different key and value for the dropdown?

What I am currently doing is below:

g.column name:  'Status',attribute: 'Status', custom_filter: %w(New Paid Cancelled), auto_reload:  true do |task| 
    @statusValsMap[task.Status] 
  end

What should I do in custom filter that its value when selected is integer which is in the database and its displays the different values?? http://wicegrid.herokuapp.com/custom_filters2

leikind commented 9 years ago

It's written in the documentation: https://github.com/leikind/wice_grid#array-of-two-element-arrays-or-a-hash

http://wicegrid.herokuapp.com/custom_filters2 is also the answer.