Activeadmin sortable by multiple columns

天涯浪子 提交于 2019-12-07 14:06:40

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!