Hiding columns using a condition #91

Merged
merged 3 commits into from Mar 6, 2014

Conversation

Projects
None yet
2 participants

iwiznia commented Mar 1, 2014

This is what's discussed in #40. You can specify :if and :unless options for a column to determine if it should be shown or not.

Readme.markdown
@@ -132,7 +132,7 @@ Datagrid supports different type of filters including:
Each column is represented by name and code block to calculate the value.
``` ruby
-column(:activated, :header => "Active", :order => "activated", :after => :name) do
+column(:activated, :header => "Active", :order => "activated", :after => :name, :if => :show_activated_coumn?, :unless => :hide_activated_coumn?) do
@bogdan

bogdan Mar 2, 2014

Owner

Dont think we need this example in Readme. It is too advanced.

lib/datagrid/columns/column.rb
@@ -99,6 +101,10 @@ def mandatory?
!! options[:mandatory]
end
+ def visible?(grid)
@bogdan

bogdan Mar 2, 2014

Owner

I would prefer enabled instead of visible because visibility is defined externally to the grid with a different mechanism.

Owner

bogdan commented Mar 4, 2014

This one looks good in general. Only two minor comments above and we can merge it.

iwiznia commented Mar 6, 2014

Changed.

iwiznia commented Mar 6, 2014

Oh... my editor removed all the trailing spaces.... is that a problem?

Owner

bogdan commented Mar 6, 2014

Of course it is a problem, trailing spaces are a part of datagrid coding style guide.
Just kidding.

bogdan added a commit that referenced this pull request Mar 6, 2014

Merge pull request #91 from iwiznia/hiding_columns
Hiding columns using a condition

@bogdan bogdan merged commit ac05f41 into bogdan:master Mar 6, 2014

iwiznia commented Mar 6, 2014

Hehehe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment