@@ -264,19 +264,16 @@ def datagrid_format_value(grid, column, model)
264
264
# Renders html table with columns defined in grid class.
265
265
# In the most common used you need to pass paginated collection
266
266
# to datagrid table because datagrid do not have pagination compatibilities:
267
- # Supported options:
268
- #
269
- # * <tt>:html</tt> - hash of attributes for <table> tag
270
- # * <tt>:order</tt> - If false do not generate ordering controlls.
271
- # Default: true.
272
- # * <tt>:columns</tt> - Array of column names to display.
273
- # Used in case when same grid class is used in different places
274
- # and needs different columns. Default: all defined columns.
275
- # * <tt>:partials</tt> - Path for partials lookup.
276
- # Default: 'datagrid'.
277
267
# @param grid [Datagrid] grid object
278
268
# @param assets [Array] objects from grid scope
279
269
# @param [Hash{Symbol => Object}] options HTML attributes to be passed to `<table>` tag
270
+ # @option options [Hash] html A hash of attributes for the `<table>` tag.
271
+ # @option options [Boolean] order Whether to generate ordering controls.
272
+ # If set to `false`, ordering controls are not generated. Default: `true`.
273
+ # @option options [Array<Symbol>] columns An array of column names to display.
274
+ # Use this when the same grid class is used in different contexts and requires different columns.
275
+ # Default: all defined columns.
276
+ # @option options [String] partials The path for partials lookup. Default: `'datagrid'`.
280
277
# @return [String] table tag HTML markup
281
278
# @example
282
279
# assets = grid.assets.page(params[:page])
@@ -294,15 +291,13 @@ def datagrid_table(grid, assets = grid.assets, **options)
294
291
295
292
# Renders HTML table header for given grid instance using columns defined in it
296
293
#
297
- # Supported options:
298
- #
299
- # * <tt>:order</tt> - display ordering controls built-in into header
300
- # Default: true
301
- # * <tt>:columns</tt> - Array of column names to display.
302
- # Used in case when same grid class is used in different places
303
- # and needs different columns. Default: all defined columns.
304
- # * <tt>:partials</tt> - Path for partials lookup.
305
- # Default: 'datagrid'.
294
+ # @option options [Boolean] order Whether to display ordering controls built into the header.
295
+ # Default: `true`.
296
+ # @option options [Array<Symbol,String>] columns An array of column names to display.
297
+ # Use this when the same grid class is used in different contexts and requires different columns.
298
+ # Default: all defined columns.
299
+ # @option options [String] partials The path for partials lookup.
300
+ # Default: `'datagrid'`.
306
301
# @param grid [Datagrid] grid object
307
302
# @param [Object] opts (deprecated) pass keyword arguments instead
308
303
# @param [Hash] options
@@ -321,19 +316,16 @@ def datagrid_header(grid, opts = :__unspecified__, **options)
321
316
# Renders HTML table rows using given grid definition using columns defined in it.
322
317
# Allows to provide a custom layout for each for in place with a block
323
318
#
324
- # Supported options:
325
- #
326
- # * <tt>:columns</tt> - Array of column names to display.
327
- # Used in case when same grid class is used in different places
328
- # and needs different columns. Default: all defined columns.
329
- # * <tt>:partials</tt> - Path for partials lookup.
330
- # Default: 'datagrid'.
331
- #
319
+ # @option options [Array<Symbol>] columns An array of column names to display.
320
+ # Use this when the same grid class is used in different contexts and requires different columns.
321
+ # Default: all defined columns.
322
+ # @option options [String] partials The path for partials lookup.
323
+ # Default: `'datagrid'`.
332
324
# @return [String]
333
- # @example
334
- # = datagrid_rows(grid) # Generic table rows Layout
335
- #
336
- # = datagrid_rows(grid) do |row| # Custom Layout
325
+ # @example Generic table rows Layout
326
+ # = datagrid_rows(grid)
327
+ # @example Custom Layout
328
+ # = datagrid_rows(grid) do |row|
337
329
# %tr
338
330
# %td= row.project_name
339
331
# %td.project-status{class: row.status}= row.status
@@ -346,11 +338,8 @@ def datagrid_rows(grid, assets = grid.assets, **options, &block)
346
338
end
347
339
348
340
# @return [String] renders ordering controls for the given column name
349
- #
350
- # Supported options:
351
- #
352
- # * <tt>:partials</tt> - Path for partials lookup.
353
- # Default: 'datagrid'.
341
+ # @option options [String] partials The path for partials lookup.
342
+ # Default: `'datagrid'`.
354
343
def datagrid_order_for ( grid , column , options = { } )
355
344
Datagrid ::Utils . warn_once ( <<~MSG )
356
345
datagrid_order_for is deprecated.
@@ -414,20 +403,19 @@ def datagrid_form_for(grid, options = {})
414
403
# @param block [Proc] block with Datagrid::Helper::HtmlRow as an argument returning a HTML markup as a String
415
404
# @param [Hash{Symbol => Object}] options
416
405
# @return [Datagrid::Helper::HtmlRow, String] captured HTML markup if block given otherwise row object
417
- # @example
418
- # # Suppose that grid has first_name and last_name columns
406
+ # @example Render default layout for row
407
+ # <%= datagrid_row(grid, user, columns: [:first_name, :last_name, :actions]) %>
408
+ # @example Rendering custom layout for `first_name` and `last_name` columns
419
409
# <%= datagrid_row(grid, user) do |row| %>
420
410
# <tr>
421
411
# <td><%= row.first_name %></td>
422
412
# <td><%= row.last_name %></td>
423
413
# </tr>
424
414
# <% end %>
425
- # @example
415
+ # @example Rendering custom layout passing a block
426
416
# <% row = datagrid_row(grid, user) %>
427
417
# First Name: <%= row.first_name %>
428
418
# Last Name: <%= row.last_name %>
429
- # @example
430
- # <%= datagrid_row(grid, user, columns: [:first_name, :last_name, :actions]) %>
431
419
def datagrid_row ( grid , asset , **options , &block )
432
420
Datagrid ::Helper ::HtmlRow . new ( self , grid , asset , options ) . tap do |row |
433
421
return capture ( row , &block ) if block_given?
0 commit comments