-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Issue #412 paginated collection scope #428
Issue #412 paginated collection scope #428
Conversation
…dCollection component When rendering a PaginatedCollection for an associated collection within the show context (for example), the :collection method called was referring to the resource rather than the passed in collection. Also raising error if collection has not been scoped with Kaminari to help new users figure it out.
…lection Setting :param_name allows you to put multiple paginated collections on a single page. (eg. Show action)
…llection When rendering a paginated collection on the show screen for example, it does not make sense to include resource download links for the collection.
I cannot seem to get multiple paginated collections to work properly (i.e. paginate) on one show view. Could someone post an example of their show action that successfully renders multiple tables with pagination? |
You'll want to set your param name if you're doing multiple paginated collections. div :id => "items" do
collection = resource.items.page(params[:item_page]).per(15)
pagination_options = {:entry_name => Item.model_name.human, :param_name => :item_page, :download_links => false}
paginated_collection(collection, pagination_options) do
table_options = { :id => 'items-table', :sortable => true, :class => "index_table", :i18n => Item }
table_for collection, table_options do
column(:code) { |resource| resource.item.code }
column(:name) { |resource| resource.item.name }
column :created_at
end
end
end |
Thanks! That was very helpful! The only problem that remains is that the "Display Items" information at the top right of the table still defaults to 1-30 despite my use of .per(15). The pagination buttons on the bottom right still increment in groups of 15, but the numbers in the top right are not correct. For a class of objects that has 194 "items", the last page of paginated hits says "Displaying Items 361 - 194 of 194 in total". I'm guessing that .per(15) in this instance does not override system defaults. |
That stuff has to do with Kaminari. You may want to take a look there and inspect your collection. I've been getting the expected results for my paginated collections so far. |
It looks like it is actually a default behavior in lib/active_admin/views/components/paginated_collection.rb. I don't see how my .per method overwrites the active_admin_application.default_per_page.
|
Adding support for the following features. These were driven by the desire to display multiple paginated collections on one page in the show action. Targets Issue #412.