-
Notifications
You must be signed in to change notification settings - Fork 127
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
Enable paginating in default index view #28
Comments
Hi! Do you mean the default table view with sorting? I didn't implement it since historically you have a lot of troubles doing drag'n'drop on a table, and also you can't have nested rows. |
No, i mean that i need just a default index view without sorting =) |
If you want the sortable view without the sortable js (why?) you can do a dirty hack and set body.active_admin .index_content .ui-sortable > * {
pointer-events: none;
} in your active_admin.css |
it's not what i want cause i want sortable tree view and plain table view) |
interesting question. You can easily have two index views, just declare them both in the admin.rb file, but how do we enable pagination for the table?
because the config is set to no pagination both views have no pagination. But we want the table to have pagination & the sortable view to not
and
did you find a good solution for this? |
My solution is to use a ActiveAdmin.register Category do
before_filter only: :index do
if presenter_config[:as] == :sortable
active_admin_config.paginate = false
active_admin_config.filters = false
end
end
end |
@zorab47 looks great, thanks. I get an undefined variable for presenter_config - how are you getting that to work? |
Ah, yes. I left out a few key things. Here is an updated example: ActiveAdmin.register Category do
controller do
before_filter only: :index do
if sortable?
active_admin_config.paginate = false
active_admin_config.filters = false
end
end
def presenter_config
active_admin_config.get_page_presenter(action_name, params[:as]) || {}
end
def sortable?
presenter_config[:as] == :sortable
end
end
end |
closer @zorab47 , but declaring the sortable tree at the top of the resource is overriding the pagination. it fetches all the items & no pagination buttons. is there a way to make that conditional too? btw, some really handy stuff above to know how to get at params, :as etc - thanks v much for sharing. |
There are other ActiveAdmin.register Category do
controller do
before_filter only: :index do
if table_presenter?
active_admin_config.paginate = true
active_admin_config.filters = true
end
end
def presenter_config
active_admin_config.get_page_presenter(action_name, params[:as]) || {}
end
def sortable_presenter?
presenter_config[:as] == :sortable
end
def table_presenter?
presenter_config[:as] == :table
end
end
end Third time is the charm. |
Hi!
I've got next problem: how can I enable sorting in a default index view?
The text was updated successfully, but these errors were encountered: