jhund / filterrific

Filterrific is a Rails Engine plugin that makes it easy to filter, search, and sort your ActiveRecord lists.
http://filterrific.clearcove.ca
MIT License
912 stars 125 forks source link

Any way to let the user specify output columns? #94

Closed awh-tokyo closed 8 years ago

awh-tokyo commented 8 years ago

I'd like checkboxes in the filters that don't actually change the filter scope, but that allow the view to selectively display columns.

I think that the first step is to make a scope

  scope :display_name, -> {
    all
  }

But is there any way that my view can know that the "display_name" scope is selected so it can display the name column?

awh-tokyo commented 8 years ago

Never mind, turns out that it's really easy:

In the model:

scope :display_name, ->(show) {
    all
  }

And in the view:

- if @filterrific.display_name
   %td= name