Philip7899
Philip7899

Reputation: 4677

can't change active_admin column width

I am using the github version of active_Admin as can be seen from my gemfile:

gem 'activeadmin', github: 'activeadmin'

I am trying to change the column width of a column in an index table. According to the documentation found here, it should be done like this:

column :notes, min_width: "400px"
column :notes, max_width: "800px"

However, the code above is not working. The column is 100px. How do I get this to work?

Upvotes: 3

Views: 6451

Answers (3)

K M Rakibul Islam
K M Rakibul Islam

Reputation: 34318

Try this:

columns do
  column max_width: "800px", min_width: "400px" do
    span "notes contents goes here"
  end
end

See Custom Column Widths section from the documentation.

Update (tested and working!)

If the above way does not work for you, you can still do it the following way:

column :notes do
   div(class: "notes") do 
     span "notes contents goes here"
   end  
end 

Define the css rule in app/assets/stylesheets/active_admin.css.scss file:

div.notes { width: 500px; }

Upvotes: 1

baash05
baash05

Reputation: 4516

This works today

index do
  style do
    [".col-name{width: 130px}"].join(' ')
  end
  column :name
  actions
end

Active admin uses this gem. https://activeadmin.github.io/arbre/

Above puts the style right into the HTML. That's okay because it works.

I mean your HTML will be ugly, but it works.

Upvotes: 1

Andrey Flegontov
Andrey Flegontov

Reputation: 61

https://github.com/activeadmin/activeadmin/issues/4091

Unfortunately max_width only exists on "pages" (i.e. register_page), and not on "resources" (i.e. register). Instead you can do this:

.col-<column_name> { max-width: 200px; }

Upvotes: 4

Related Questions