Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Allow HTML class to be specified for each column in the report. #50

Merged
merged 1 commit into from

2 participants

@mipearson
Collaborator

We're bad and occasionally use non-semantic CSS classes. Eg, I've used this patch to specify :class => 'nowrap' on many of the report columns.

I couldn't find a spec for datagrid_column_classes. If there is one, and I've missed it, let me know and I'll write a test.

Also as you use a wiki rather than putting the documentation in the source I have not included a documentation update.

@bogdan
Owner

Can we allow to specify all set of HTML attributes with :html option, like column(:id, :html => {:class => "nowrap", :something => "else"}?

I believe this is more flexible.

Please include a unit test for this.

@mipearson
Collaborator

Won't this conflict with the existing :html => true option?

@bogdan
Owner

Hm, true.

Let it be only class now.

Please add a test.

@mipearson
Collaborator

Test added.

@bogdan bogdan merged commit 39f8048 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 2 deletions.
  1. +2 −2 lib/datagrid/helper.rb
  2. +11 −0 spec/datagrid/helper_spec.rb
View
4 lib/datagrid/helper.rb
@@ -31,8 +31,8 @@ def datagrid_renderer
end
def datagrid_column_classes(grid, column)
- order_class = grid.order == column.name ? ["ordered", grid.descending ? "desc" : "asc"] : nil
- [column.name, order_class].compact.join(" ")
+ order_class = grid.order == column.name ? ["ordered", grid.descending ? "desc" : "asc"] : nil
+ [column.name, order_class, column.options[:class]].compact.join(" ")
end
end
end
View
11 spec/datagrid/helper_spec.rb
@@ -176,6 +176,17 @@
)
end
+ it "should allow CSS classes to be specified for a column" do
+ rp = test_report do
+ scope { Entry }
+ column(:name, :class => 'my_class')
+ end
+
+ subject.datagrid_rows(rp, [entry]).should match_css_pattern(
+ "tr td.name.my_class" => "Star"
+ )
+ end
+
end
describe ".datagrid_order_for" do
Something went wrong with that request. Please try again.