Class: TableSettings::Column
- Inherits:
-
Object
- Object
- TableSettings::Column
- Defined in:
- lib/table_settings/table_column.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#index ⇒ Object
Returns the value of attribute index.
Instance Method Summary collapse
- #column_hash ⇒ Object
- #css_class(class_name) ⇒ Object
- #css_header_class(class_name) ⇒ Object
-
#csv_excluded(bool = true) ⇒ Object
Set if column is excluded from csv export.
-
#editable(bool = true) ⇒ Object
For editable table, defines wchich column should be editable.
- #filter_data(array) ⇒ Object
- #filter_type(filter_type) ⇒ Object
- #format_method(method_name) ⇒ Object
-
#global_format_method(method_name) ⇒ Object
Sets global format method used for values.
-
#inactive_filter(bool = true) ⇒ Object
When using the filter box in header but filters in own way, not by table (just passing already filtered AREL to table).
-
#initialize(table_settings, index) ⇒ Column
constructor
A new instance of Column.
- #max_text_length(length) ⇒ Object
-
#non_breakable(bool = true) ⇒ Object
Defines column with non-breakable content (for example column with more buttons).
-
#non_sortable(bool = true) ⇒ Object
Defines column with non-sortable content.
-
#sql_expression(expression) ⇒ Object
Defines select expression for column (ie. select count(id) as counter).
-
#summarize_all(enabled = true, label = nil) ⇒ Object
Sets if column has summarization cell per table Standard column will be computed Custom column have to set TableSettings::Buttons.summarize_all_value in callback method.
-
#summarize_page(enabled = true, label = nil) ⇒ Object
Sets if column has summarization cell per page Standard column will be computed Custom column have to set TableSettings::Buttons.summarize_page_value in callback method.
-
#title(string) ⇒ Object
Help Title (for mouseover) of column, no title means usage of value.
Constructor Details
#initialize(table_settings, index) ⇒ Column
Returns a new instance of Column.
8 9 10 11 12 |
# File 'lib/table_settings/table_column.rb', line 8 def initialize(table_settings, index) @table_settings = table_settings @column_hash = {} @index = index end |
Instance Attribute Details
#index ⇒ Object
Returns the value of attribute index.
6 7 8 |
# File 'lib/table_settings/table_column.rb', line 6 def index @index end |
Instance Method Details
#column_hash ⇒ Object
14 15 16 |
# File 'lib/table_settings/table_column.rb', line 14 def column_hash @column_hash end |
#css_class(class_name) ⇒ Object
18 19 20 21 22 |
# File 'lib/table_settings/table_column.rb', line 18 def css_class(class_name) @column_hash[:class] = class_name self end |
#css_header_class(class_name) ⇒ Object
23 24 25 26 27 |
# File 'lib/table_settings/table_column.rb', line 23 def css_header_class(class_name) @column_hash[:header_class] = class_name self end |
#csv_excluded(bool = true) ⇒ Object
Set if column is excluded from csv export
133 134 135 136 |
# File 'lib/table_settings/table_column.rb', line 133 def csv_excluded(bool = true) @column_hash[:csv_excluded] = bool self end |
#editable(bool = true) ⇒ Object
For editable table, defines wchich column should be editable
121 122 123 124 |
# File 'lib/table_settings/table_column.rb', line 121 def editable(bool = true) @column_hash[:editable] = bool self end |
#filter_data(array) ⇒ Object
47 48 49 50 51 |
# File 'lib/table_settings/table_column.rb', line 47 def filter_data(array) @column_hash[:filter_data] = array self end |
#filter_type(filter_type) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/table_settings/table_column.rb', line 29 def filter_type(filter_type) if filter_type == :none @column_hash.delete(:filter) else @column_hash[:filter] = filter_type end self end |
#format_method(method_name) ⇒ Object
59 60 61 62 63 |
# File 'lib/table_settings/table_column.rb', line 59 def format_method(method_name) @column_hash[:format_method] = method_name self end |
#global_format_method(method_name) ⇒ Object
Sets global format method used for values
66 67 68 69 70 |
# File 'lib/table_settings/table_column.rb', line 66 def global_format_method(method_name) @column_hash[:global_format_method] = method_name self end |
#inactive_filter(bool = true) ⇒ Object
When using the filter box in header but filters in own way, not by table (just passing already filtered AREL to table)
127 128 129 130 |
# File 'lib/table_settings/table_column.rb', line 127 def inactive_filter(bool = true) @column_hash[:inactive_filter] = bool self end |
#max_text_length(length) ⇒ Object
53 54 55 56 57 |
# File 'lib/table_settings/table_column.rb', line 53 def max_text_length(length) @column_hash[:max_text_length] = length self end |
#non_breakable(bool = true) ⇒ Object
Defines column with non-breakable content (for example column with more buttons)
107 108 109 110 |
# File 'lib/table_settings/table_column.rb', line 107 def non_breakable(bool = true) @column_hash[:non_breakable] = bool self end |
#non_sortable(bool = true) ⇒ Object
Defines column with non-sortable content. Affects only standard columns. Sortable if not set.
116 117 118 |
# File 'lib/table_settings/table_column.rb', line 116 def non_sortable(bool = true) @column_hash[:non_sortable] = bool end |
#sql_expression(expression) ⇒ Object
Defines select expression for column (ie. select count(id) as counter)
42 43 44 45 |
# File 'lib/table_settings/table_column.rb', line 42 def sql_expression(expression) @column_hash[:sql_expression] = expression self end |
#summarize_all(enabled = true, label = nil) ⇒ Object
Sets if column has summarization cell per table Standard column will be computed Custom column have to set TableSettings::Buttons.summarize_all_value in callback method
97 98 99 100 101 |
# File 'lib/table_settings/table_column.rb', line 97 def summarize_all(enabled = true, label = nil) @column_hash[:summarize_all] = true @column_hash[:summarize_all_label] = label unless label.nil? self end |
#summarize_page(enabled = true, label = nil) ⇒ Object
Sets if column has summarization cell per page Standard column will be computed Custom column have to set TableSettings::Buttons.summarize_page_value in callback method
84 85 86 87 88 |
# File 'lib/table_settings/table_column.rb', line 84 def summarize_page(enabled = true, label = nil) @column_hash[:summarize_page] = true @column_hash[:summarize_page_label] = label unless label.nil? self end |
#title(string) ⇒ Object
Help Title (for mouseover) of column, no title means usage of value
73 74 75 |
# File 'lib/table_settings/table_column.rb', line 73 def title(string) @column_hash[:title] = string end |