class ActiveAdmin::Views::Column

def build(options = {})

Options Hash: (**options)
  • :span (Integer) -- The columns this column should span

Parameters:
  • options (Hash) -- An options hash for the column
def build(options = {})
  options = options.dup
  @span_size = options.delete(:span) || 1
  @max_width = options.delete(:max_width)
  @min_width = options.delete(:min_width)
  super(options)
end

def safe_width(width)

Converts values without a '%' or 'px' suffix to a pixel value
def safe_width(width)
  width.to_s.gsub(/\A(\d+)\z/, '\1px')
end

def set_column_styles(column_width, margin_width, is_last_column = false)

def set_column_styles(column_width, margin_width, is_last_column = false)
  column_with_span_width = (span_size * column_width) + ((span_size - 1) * margin_width)
  styles = []
  styles << "width: #{column_with_span_width}%;"
  if max_width
    styles << "max-width: #{safe_width(max_width)};"
  end
  if min_width
    styles << "min-width: #{safe_width(min_width)};"
  end
  styles << "margin-right: #{margin_width}%;" unless is_last_column
  set_attribute :style, styles.join(" ")
end