ActiveAdmin报表中的项目编号 [英] Numbering items in an ActiveAdmin Report
本文介绍了ActiveAdmin报表中的项目编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在ActiveAdmin中获取每个项目的顺序号?
Is it possible to get the sequential number of each item in ActiveAdmin?
所以看起来像这样:
| Number | Name |
| 1 | Bill |
| 2 | Smith |
我知道这可以通过 each_with_index
来实现
I know this can be achieved with each_with_index
but don't think there is a way to use this with ActiveAdmin.
是否可以像 controller一样添加一些内容 c >?
我想将此功能添加到ActiveAdmin的索引中,例如
I want to add this functionality into an index on ActiveAdmin so for example
index do
column "Number" do |a|
# Some way of specifying index number
end
column "Name" do |a|
a.name
end
end
谢谢
推荐答案
这是可行的:
index do
@index = 30 * (((params[:page] || 1).to_i) - 1) # 30 needs to set to that what your page size is
column :number do
@index += 1
end
end
更新:方式上有一个构建实现:
UPDATE: There is a build in implementation on the way:
index do
selectable_column
index_column
column ...
end
这篇关于ActiveAdmin报表中的项目编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文