unnamed_road
unnamed_road

Reputation: 129

How to render column conditionally for ActiveAdmin `table_for` array collection

I have an array versions that I render on ActiveAdmin custom page (.html.arb), and I need to show some columns depending on the array element's value, but I struggle to understand how to loop over this array and apply conditional rendering

table_for versions do |element|
   ...
   column 'Example' if element == value
   ...
end

element class, in this case, is ActiveAdmin::Views::TableFor which is logical, but I can't understand how I can access versions items in this loop as their original class (Integer), so my element would be Integer too. Thanks for help in advance

Upvotes: 2

Views: 426

Answers (2)

Angel Pino
Angel Pino

Reputation: 1

Using jQuery, you can hide a column. For example:

̣``` if $("td.col.col-grado").text() == "0.0".repeat($("td.col.col-grado").length) $("th.col.col-grado").hide() $("td.col.col-grado").hide() if $("td.co.col-botella").text == "" $("th.col.col-botella").hide() $("td.col.col-botella").hide()

Upvotes: 0

Fivell
Fivell

Reputation: 11929

Hello implementation of table_for is not supporting it, I suggest you to create partials and pick it by name using your conditional logic instead

Upvotes: 2

Related Questions