Module: Datagrid::Ordering
- Included in:
- Base
- Defined in:
- lib/datagrid/ordering.rb
Overview
Module adds support for ordering by defined columns for Datagrid.
Instance Method Summary collapse
-
#order_column ⇒ Datagrid::Columns::Column?
A column definition that is currently used to order assets.
-
#ordered_by?(column, desc = nil) ⇒ Boolean
True if given grid is ordered by given column.
Instance Method Details
#order_column ⇒ Datagrid::Columns::Column?
Returns a column definition that is currently used to order assets.
50 51 52 |
# File 'lib/datagrid/ordering.rb', line 50 def order_column order ? column_by_name(order) : nil end |
#ordered_by?(column, desc = nil) ⇒ Boolean
Returns true if given grid is ordered by given column.
57 58 59 60 |
# File 'lib/datagrid/ordering.rb', line 57 def ordered_by?(column, desc = nil) order_column == column_by_name(column) && (desc.nil? || (desc ? descending? : !descending?)) end |