Skip to content

Commit fd9d33a

Browse files
committed
Enhance columns and filters doc
- Updated `order` and `order_desc` options to accept `Proc` for dynamic ordering logic. - Improved `if` and `unless` options to accept `Symbol` or `Proc` for conditional column availability. - Enhanced documentation for better clarity on usage and examples.
1 parent 63a91d7 commit fd9d33a

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

lib/datagrid/columns.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,20 +265,22 @@ def columns(*column_names, data: false, html: false)
265265
# @param block [Block] proc to calculate a column value
266266
# @option options [Boolean, String] html Determines if the column should be present
267267
# in the HTML table and how it is formatted.
268-
# @option options [String, Array<Symbol>] order Determines if the column can be sortable and
268+
# @option options [String, Array<Symbol>, Proc] order Determines if the column can be sortable and
269269
# specifies the ORM ordering method.
270270
# Example: `"created_at, id"` for ActiveRecord, `[:created_at, :id]` for Mongoid.
271-
# @option options [String] order_desc Specifies a descending order for the column
272-
# (used when `:order` cannot be easily reversed by the ORM).
271+
# Can be a Proc accepting a scope argument and returning a scope with applied order
272+
# @option options [String, Array<Symbol>, Proc] order_desc Specifies a descending order for the column.
273+
# See `order` option for context.
274+
# Used when `:order` cannot be easily reversed by the ORM.
273275
# @option options [Boolean, Proc] order_by_value Enables Ruby-level ordering for the column.
274276
# Warning: Sorting large datasets in Ruby is not recommended.
275277
# If `true`, Datagrid orders by the column value.
276278
# If a block is provided, Datagrid orders by the block's return value.
277279
# @option options [Boolean] mandatory If `true`, the column will never be hidden by the `#column_names` selection.
278280
# @option options [Symbol] before Places the column before the specified column when determining order.
279281
# @option options [Symbol] after Places the column after the specified column when determining order.
280-
# @option options [Boolean, Proc] if conditions when a column is available.
281-
# @option options [Boolean, Proc] unless conditions when a column is not available.
282+
# @option options [Symbol, Proc] if conditions when a column is available, can be a method name or a proc with grid argument returning `Boolean`.
283+
# @option options [Symbol, Proc] unless conditions when a column is not available, can be a method name or a proc with grid argument returning `Boolean`.
282284
# @option options [Symbol, Array<Symbol>] preload Specifies associations
283285
# to preload for the column within the scope.
284286
# @option options [Hash] tag_options Specifies HTML attributes for the `<td>` or `<th>` of the column.

0 commit comments

Comments
 (0)