Reputation: 2917
I have been populating my dashboard page with tables without rendering any html
. But i need to sort or filter table according to a column value which has boolean value in the db. Nothing happens with the sortable
tag
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
Is it possible in ActiveAdmin Dasboard
?
ActiveAdmin.register_page "Dashboard" do
Upvotes: 0
Views: 769
Reputation: 2917
In case someone needs help in the future to customize the sorting:
test_order = if params[:order]
params[:order].gsub(/[^a-z_]/,'').gsub(/_(asc|desc)$/, ' \1') #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
resource taken from: https://github.com/activeadmin/activeadmin/issues/4483#issuecomment-237073696
Upvotes: 1