Method: BootstrapTableHelper::Table#column

Defined in:
app/helpers/bootstrap_table_helper.rb

#column(width = nil, method = nil, options = {}, &block) ⇒ Object

options

width - 1~12
method - object's method, use send(method) to get value
h - options of header


61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'app/helpers/bootstrap_table_helper.rb', line 61

def column(width=nil, method=nil, options={}, &block)
  width, method, options = nil, nil, width if width.is_a?(Hash)
  method, options = nil, method if method.is_a?(Hash)

  header_options = options.delete(:h) || {}
  header_options.reverse_merge!(w: width) if width && width.to_i < 12 && width.to_i > 0
  if method
    options.reverse_merge!(method: method)
    align = case options[:align]
      when 'center'
        :t
      when 'right'
        :r
      else
        :l
    end

    header_options.reverse_merge!(align => self.options[:obj].first.class.human_attribute_name(method)) unless self.options[:obj].empty?
  end

  headers << header_options unless header_options.empty?


  columns << [options, block]
end