-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Pagination on table_for inside sections and panels #1116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I have following code to do that panel :test do
paginated_collection(my_collection.page(params[:page]).per(15), download_links: false) do
table_for(collection, sortable: false) do
column :start
column :stop
column :duration
end
end
end |
Awesome, thanks huk, will give it a go! |
Doesnt work with will_paginate, When I use above code it gives error as method "per" undefined for activerelation object. |
@jbmyid please read this, that should be help |
Already did that but did not solve the problem, if defined?(WillPaginate)
ActiveSupport.on_load :active_record do
module WillPaginate
module ActiveRecord
module RelationMethods
def per(value = nil) per_page(value) end
def total_count() count end
end
end
module CollectionMethods
alias_method :num_pages, :total_pages
end
end
end
end |
have you tried this: panel :test do
# use per_page_kaminari here to get compatibility
paginated_collection(my_collection.page(params[:page]).per_page_kaminari(15), download_links: false) do
table_for(collection, sortable: false) do
column :start
column :stop
column :duration
end
end
end
Kaminari.configure do |config|
config.page_method_name = :per_page_kaminari
end |
@timoschilling Yeh tried that as well but, got stack overflow infinite loop with per_page_kaminari. |
@jdmyid me, too. |
guys, using will_paginate and it doesnt work, how could I handle that issue? |
I have the Kaminari initializer setup appropriately and using the following code. Getting stack error: users = role.users
panel 'Users' do
paginated_collection(users.page(params[:page]).per_page_kaminari(15), download_links: false) do
table_for(collection, sortable: false) do
column :id
end
end
end
|
OK, with some debugging I realized what is the issue. It's the combination of So, if you're getting undefined method error when calling it with just panel :test do
paginated_collection(my_collection.per_page_kaminari(params[:page]).per(15), download_links: false) do
table_for(collection, sortable: false) do
column :start
column :stop
column :duration
end
end
end In other words, it's not the |
Just in case someone stumbles on this thread, this is what worked for me: Szenario: Active admin view with multiple, separately paginated lists. Gemfile: column do
panel "PanelName" do
paginated_collection(user.something_scope.page(params[:somethings_page]).per(10), param_name: :somethings_page, download_links: false) do
table_for(collection) do
column 'Titel' do |something|
link_to(something.title, backoffice_something_path(something))
end
end
end
end
end No additional code was needed. |
Thanks everyone for AA, this is absolutely wicked!
Would love to see a way to implement a DRY pagination to table_for inside sections and panels on both the dashboard and in model show pages when displaying its children items
Sorry if this is already out there.
The text was updated successfully, but these errors were encountered: