如何在 ActiveAdmin 的仪表板中使列可排序?

How to make a column sortable in Dashboard in ActiveAdmin?

我一直在用 table 填充我的仪表板页面,但没有呈现任何 html。但我需要根据数据库中具有布尔值的列值对 table 进行排序或过滤。 sortable 标签

没有任何反应
tab "test" do
        columns  do
          panel "test" do

            table_for Test.all do

              column "Name", :name

              column "status", :status, :sortable => :status  # this needs to be sortable


            end
          end
        end
      end

ActiveAdmin Dasboard可以吗?

ActiveAdmin.register_page "Dashboard" do

如果将来有人需要帮助来自定义排序:

test_order = if params[:order]
              params[:order].gsub(/[^a-z_]/,'').gsub(/_(asc|desc)$/, ' ') #sanitize and convert to order expression
            else
              "status desc" #default
            end

table_for Test.all.order(test_order), sortable: true, class: 'index_table'  do

              column "Name", :name, sortable: false #to hide sorting name

              column :status
            end
          end
        end

资源取自:https://github.com/activeadmin/activeadmin/issues/4483#issuecomment-237073696