简体   繁体   English

如何在活动管理员的同一页面上定义多个分页器?

[英]How do i define multiple paginators for the same page on active admin?

I am trying to create a simple dashboard on active admin. 我正在尝试在活动管理员上创建一个简单的仪表板。

The idea here is to have multiple panels that serve as a quick view of different models. 这里的想法是拥有多个面板,以快速查看不同的模型。 The problem is that when I move between pages it affects all paginators. 问题是,当我在页面之间移动时,它会影响所有分页器。

I am doing this 我正在做这个

paginated_collection(my_collection.page(params[:page_2]).per(5)) do
   table_for collection do |t|
       ...
   end
end

Is it possible to have multiple paginators on active admin for the same page? 同一页面上可以在活动管理员上使用多个分页器吗?

It is possible to set the name of the page param. 可以设置页面参数的名称。 This question is closely related to this answer: https://stackoverflow.com/a/6721703/790737 . 该问题与以下答案密切相关: https : //stackoverflow.com/a/6721703/790737 ActiveAdmin wraps Kaminari, but will pass the param_name parameter to the pagination links. ActiveAdmin包装了Kaminari,但是会将param_name参数传递给分页链接。 So I think you should be able to write: 所以我认为您应该能够写:

paginated_collection(my_collection.page(params["custom_page_param"]).per(5), :param_name => 'custom_page_param') do
  table_for collection do |t|
     ...
  end
end

Good luck! 祝好运!

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

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