简体   繁体   English

无法更改 active_admin 列宽

[英]can't change active_admin column width

I am using the github version of active_Admin as can be seen from my gemfile:从我的 gemfile 中可以看出,我正在使用 active_Admin 的 github 版本:

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.列是 100px。 How do I get this to work?我如何让这个工作?

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

Unfortunately max_width only exists on "pages" (ie register_page), and not on "resources" (ie register).不幸的是,max_width 只存在于“页面”(即 register_page)上,而不存在于“资源”(即寄存器)上。 Instead you can do this:相反,您可以这样做:

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

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:app/assets/stylesheets/active_admin.css.scss文件中定义 css 规则:

div.notes { width: 500px; }

This works today这今天有效

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

Active admin uses this gem.活跃的管理员使用这个 gem。 https://activeadmin.github.io/arbre/ https://activeadmin.github.io/arbre/

Above puts the style right into the HTML.上面将样式直接放入 HTML 中。 That's okay because it works.没关系,因为它有效。

I mean your HTML will be ugly, but it works.我的意思是你的 HTML 会很丑,但它有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM