Class: DataGrid::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/data_grid/column.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(column_field, attrs = {}) ⇒ Column



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/data_grid/column.rb', line 8

def initialize(column_field, attrs = {})
  self.sortable = attrs[:sortable] || DataGrid.column_sortable 
  self.title = attrs[:title]
  self.field = column_field
  self.sort_by = attrs[:sort_by] || self.field
  self.filter = attrs[:filter]
  self.filter_data = []
  self.style = attrs[:style]
  self.summary = attrs[:summary]
  self.global_summary = attrs[:global_summary]
  self.summary_formatter = attrs[:summary_formatter] || DataGrid.column_summary_formatter
  self.formatter = attrs[:formatter]
  self.filter_by = attrs[:filter_by] || self.field
  self.hide_in_export = attrs[:hide_in_export] || false
  self.css_class = attrs[:css_class] || ''
  self.auto_filter_hash = attrs[:auto_filter_hash]
end

Instance Attribute Details

#auto_filter_hashObject

Returns the value of attribute auto_filter_hash.



6
7
8
# File 'lib/data_grid/column.rb', line 6

def auto_filter_hash
  @auto_filter_hash
end

#css_classObject

Returns the value of attribute css_class.



6
7
8
# File 'lib/data_grid/column.rb', line 6

def css_class
  @css_class
end

#fieldObject

Returns the value of attribute field.



6
7
8
# File 'lib/data_grid/column.rb', line 6

def field
  @field
end

#filterObject

Returns the value of attribute filter.



6
7
8
# File 'lib/data_grid/column.rb', line 6

def filter
  @filter
end

#filter_byObject

Returns the value of attribute filter_by.



6
7
8
# File 'lib/data_grid/column.rb', line 6

def filter_by
  @filter_by
end

#filter_dataObject

Returns the value of attribute filter_data.



6
7
8
# File 'lib/data_grid/column.rb', line 6

def filter_data
  @filter_data
end

#filter_valueObject

Returns the value of attribute filter_value.



6
7
8
# File 'lib/data_grid/column.rb', line 6

def filter_value
  @filter_value
end

#formatterObject

Returns the value of attribute formatter.



6
7
8
# File 'lib/data_grid/column.rb', line 6

def formatter
  @formatter
end

#global_summaryObject

Returns the value of attribute global_summary.



6
7
8
# File 'lib/data_grid/column.rb', line 6

def global_summary
  @global_summary
end

#hide_in_exportObject

Returns the value of attribute hide_in_export.



6
7
8
# File 'lib/data_grid/column.rb', line 6

def hide_in_export
  @hide_in_export
end

#sort_byObject

Returns the value of attribute sort_by.



6
7
8
# File 'lib/data_grid/column.rb', line 6

def sort_by
  @sort_by
end

#sortableObject

Returns the value of attribute sortable.



6
7
8
# File 'lib/data_grid/column.rb', line 6

def sortable
  @sortable
end

#styleObject

Returns the value of attribute style.



6
7
8
# File 'lib/data_grid/column.rb', line 6

def style
  @style
end

#summaryObject

Returns the value of attribute summary.



6
7
8
# File 'lib/data_grid/column.rb', line 6

def summary
  @summary
end

#summary_formatterObject

Returns the value of attribute summary_formatter.



6
7
8
# File 'lib/data_grid/column.rb', line 6

def summary_formatter
  @summary_formatter
end

#titleObject

Returns the value of attribute title.



6
7
8
# File 'lib/data_grid/column.rb', line 6

def title
  @title
end

Instance Method Details

#filter_active?Boolean



34
35
36
# File 'lib/data_grid/column.rb', line 34

def filter_active?
  !self.filter_value.to_s.split(DataGrid.range_separator).first.blank?
end

#sort_fieldObject



26
27
28
29
30
31
32
# File 'lib/data_grid/column.rb', line 26

def sort_field
  if self.field.class == Symbol
    return self.sort_by ? self.sort_by : self.field
  else
    return self.sort_by
  end
end