问题
Is there any possibility to sort activeadmin
table using multiple columns?
I've found an issue that says it is impossible now. But I wonder if anyone has implemented such functionality?
回答1:
I've faced same issue. Judging by source code this feature isn't supported
def sort_order(chain)
params[:order] ||= active_admin_config.sort_order
if params[:order] && params[:order] =~ /^([\w\_\.]+)_(desc|asc)$/
column = $1
order = $2
table = active_admin_config.resource_table_name
table_column = (column =~ /\./) ? column :
"#{table}.#{active_admin_config.resource_quoted_column_name(column)}"
chain.reorder("#{table_column} #{order}")
else
chain # just return the chain
end
end
But there is monkey patch solution.
来源:https://stackoverflow.com/questions/12565219/activeadmin-sortable-by-multiple-columns