Module: Datagrid::Helper
- Defined in:
- lib/datagrid/helper.rb,
lib/datagrid/renderer.rb
Defined Under Namespace
Classes: HtmlRow
Instance Method Summary collapse
-
#datagrid_form_for(grid, options = {}) ⇒ String
Renders HTML for for grid with all filters inputs and lables defined in it.
-
#datagrid_header(grid, options = {}) ⇒ String
Renders HTML table header for given grid instance using columns defined in it.
-
#datagrid_order_for(grid, column, options = {}) ⇒ Object
Renders ordering controls for the given column name.
-
#datagrid_order_path(grid, column, descending) ⇒ String
Generates an ascending or descending order url for the given column.
-
#datagrid_row(grid, asset, **options, &block) ⇒ Datagrid::Helper::HtmlRow, String
Provides access to datagrid columns data.
-
#datagrid_rows(grid, assets = grid.assets, **options, &block) ⇒ Object
Renders HTML table rows using given grid definition using columns defined in it.
-
#datagrid_table(grid, assets = grid.assets, **options) ⇒ String
Renders html table with columns defined in grid class.
-
#datagrid_value(grid, column, model) ⇒ Object
Individual cell value from the given grid, column name and model.
Instance Method Details
#datagrid_form_for(grid, options = {}) ⇒ String
Renders HTML for for grid with all filters inputs and lables defined in it
Supported options:
-
:partials
- Path for form partial lookup. Default: ‘datagrid’. -
All options supported by Rails
form_for
helper
108 109 110 |
# File 'lib/datagrid/helper.rb', line 108 def datagrid_form_for(grid, = {}) datagrid_renderer.form_for(grid, ) end |
#datagrid_header(grid, options = {}) ⇒ String
Renders HTML table header for given grid instance using columns defined in it
Supported options:
-
:order
- display ordering controls built-in into header Default: true -
:columns
- Array of column names to display. Used in case when same grid class is used in different places and needs different columns. Default: all defined columns. -
:partials
- Path for partials lookup. Default: ‘datagrid’.
62 63 64 |
# File 'lib/datagrid/helper.rb', line 62 def datagrid_header(grid, = {}) datagrid_renderer.header(grid, ) end |
#datagrid_order_for(grid, column, options = {}) ⇒ Object
Renders ordering controls for the given column name
Supported options:
-
:partials
- Path for partials lookup. Default: ‘datagrid’.
95 96 97 |
# File 'lib/datagrid/helper.rb', line 95 def datagrid_order_for(grid, column, = {}) datagrid_renderer.order_for(grid, column, ) end |
#datagrid_order_path(grid, column, descending) ⇒ String
Generates an ascending or descending order url for the given column
141 142 143 |
# File 'lib/datagrid/helper.rb', line 141 def datagrid_order_path(grid, column, descending) datagrid_renderer.order_path(grid, column, descending, request) end |
#datagrid_row(grid, asset, **options, &block) ⇒ Datagrid::Helper::HtmlRow, String
Provides access to datagrid columns data. Used in case you want to build html table completelly manually
132 133 134 |
# File 'lib/datagrid/helper.rb', line 132 def datagrid_row(grid, asset, **, &block) datagrid_renderer.row(grid, asset, **, &block) end |
#datagrid_rows(grid, assets = grid.assets, **options, &block) ⇒ Object
Renders HTML table rows using given grid definition using columns defined in it. Allows to provide a custom layout for each for in place with a block
Supported options:
-
:columns
- Array of column names to display. Used in case when same grid class is used in different places and needs different columns. Default: all defined columns. -
:partials
- Path for partials lookup. Default: ‘datagrid’.
85 86 87 |
# File 'lib/datagrid/helper.rb', line 85 def datagrid_rows(grid, assets = grid.assets, **, &block) datagrid_renderer.rows(grid, assets, **, &block) end |
#datagrid_table(grid, assets = grid.assets, **options) ⇒ String
Renders html table with columns defined in grid class. In the most common used you need to pass paginated collection to datagrid table because datagrid do not have pagination compatibilities: Supported options:
-
:html
- hash of attributes for <table> tag -
:order
- If false do not generate ordering controlls. Default: true. -
:columns
- Array of column names to display. Used in case when same grid class is used in different places and needs different columns. Default: all defined columns. -
:partials
- Path for partials lookup. Default: ‘datagrid’.
45 46 47 |
# File 'lib/datagrid/helper.rb', line 45 def datagrid_table(grid, assets = grid.assets, **) datagrid_renderer.table(grid, assets, **) end |
#datagrid_value(grid, column, model) ⇒ Object
Returns individual cell value from the given grid, column name and model.
17 18 19 |
# File 'lib/datagrid/helper.rb', line 17 def datagrid_value(grid, column, model) datagrid_renderer.format_value(grid, column, model) end |