Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I pass options in simple_table_for that can be used by the report? #46

Open
awh-tokyo opened this issue Mar 23, 2015 · 2 comments
Open

Comments

@awh-tokyo
Copy link

The documentation specifies that we can conditionally display columns like so:

column :email, if: :admin?

Where "admin?" is defined in the report class.

What I'd like to do is pass some report options through this line:

<%= simple_table_for @users, with: UserTable %>

, those options being visible by the report class's methods.

My application has a few different ways of listing the same data, so it makes sense that I should have a single table definition and then just conditionally display the appropriate columns.

@bobbytables
Copy link
Owner

Yeah, this has been a bottleneck for me in the past as well. I'm not sure how to currently implement it within the design choices of table cloth.

Also, sorry for this delayed response. Slipped by.

@awh-tokyo
Copy link
Author

FYI, for anybody else who has the same issue, this is what I ended up doing. It's not beautiful, but it works:

<% @report_type = "multi_history" %>
<%= simple_table_for @inventory_histories, with: InventoryHistoryTable %>

then, in the table definition:

def show_vendor?
view.instance_variable_get(:@report_type).eql?("multi_history")
end

def show_actors?
view.instance_variable_get(:@report_type).eql?("part_history")
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants