Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3- Active Admin (Formtastic), set column Width

I am customizing the index form in active admin. I have some columns like:

column :id
column :name 

I want to set the width of those columns. Is there an easy way?

like image 376
Tony Avatar asked Jan 03 '12 18:01

Tony


3 Answers

for example:

column :name do |name|
   div :class => "name" do 
     name  
   end  
end  

then in app/assets/stylesheets/active_admin.css.scss file:

div.name { width: 500px; }

this should work I guess

like image 196
Vlad Khomich Avatar answered Sep 28 '22 22:09

Vlad Khomich


The easiest way would be to wait for a version of active_admin that offers the feature Greg Bell talks about in https://github.com/gregbell/active_admin/issues/63

There is currently not an 'easy way' to do this.

like image 29
Sjors Branderhorst Avatar answered Sep 28 '22 20:09

Sjors Branderhorst


No need to create any div class. For:

column :name

In app/assets/stylesheets/active_admin.css.scss file write:

.active_admin {
  .index_as_table {
    td.name {
      max-width: 150px;
      min-width: 100px;
    }
  }
}

To set the max-width of the columns admin panel wide write:

.active_admin {
  .index_as_table {
    td {
      max-width: 150px;      
    }
  }
}

If you're using other index renderers, just have a look the source html and tweak the active admin stylesheet accordingly.

like image 39
Musaffa Avatar answered Sep 28 '22 22:09

Musaffa