@@ -268,19 +268,16 @@ def datagrid_format_value(grid, column, model)
268
268
# Renders html table with columns defined in grid class.
269
269
# In the most common used you need to pass paginated collection
270
270
# to datagrid table because datagrid do not have pagination compatibilities:
271
- # Supported options:
272
- #
273
- # * <tt>:html</tt> - hash of attributes for <table> tag
274
- # * <tt>:order</tt> - If false do not generate ordering controlls.
275
- # Default: true.
276
- # * <tt>:columns</tt> - Array of column names to display.
277
- # Used in case when same grid class is used in different places
278
- # and needs different columns. Default: all defined columns.
279
- # * <tt>:partials</tt> - Path for partials lookup.
280
- # Default: 'datagrid'.
281
271
# @param grid [Datagrid] grid object
282
272
# @param assets [Array] objects from grid scope
283
273
# @param [Hash{Symbol => Object}] options HTML attributes to be passed to `<table>` tag
274
+ # @option options [Hash] html A hash of attributes for the `<table>` tag.
275
+ # @option options [Boolean] order Whether to generate ordering controls.
276
+ # If set to `false`, ordering controls are not generated. Default: `true`.
277
+ # @option options [Array<Symbol>] columns An array of column names to display.
278
+ # Use this when the same grid class is used in different contexts and requires different columns.
279
+ # Default: all defined columns.
280
+ # @option options [String] partials The path for partials lookup. Default: `'datagrid'`.
284
281
# @return [String] table tag HTML markup
285
282
# @example
286
283
# assets = grid.assets.page(params[:page])
@@ -291,15 +288,13 @@ def datagrid_table(grid, assets = grid.assets, **options)
291
288
292
289
# Renders HTML table header for given grid instance using columns defined in it
293
290
#
294
- # Supported options:
295
- #
296
- # * <tt>:order</tt> - display ordering controls built-in into header
297
- # Default: true
298
- # * <tt>:columns</tt> - Array of column names to display.
299
- # Used in case when same grid class is used in different places
300
- # and needs different columns. Default: all defined columns.
301
- # * <tt>:partials</tt> - Path for partials lookup.
302
- # Default: 'datagrid'.
291
+ # @option options [Boolean] order Whether to display ordering controls built into the header.
292
+ # Default: `true`.
293
+ # @option options [Array<Symbol,String>] columns An array of column names to display.
294
+ # Use this when the same grid class is used in different contexts and requires different columns.
295
+ # Default: all defined columns.
296
+ # @option options [String] partials The path for partials lookup.
297
+ # Default: `'datagrid'`.
303
298
# @param grid [Datagrid] grid object
304
299
# @param [Hash] options
305
300
# @return [String] HTML table header tag markup
@@ -310,19 +305,16 @@ def datagrid_header(grid, options = {})
310
305
# Renders HTML table rows using given grid definition using columns defined in it.
311
306
# Allows to provide a custom layout for each for in place with a block
312
307
#
313
- # Supported options:
314
- #
315
- # * <tt>:columns</tt> - Array of column names to display.
316
- # Used in case when same grid class is used in different places
317
- # and needs different columns. Default: all defined columns.
318
- # * <tt>:partials</tt> - Path for partials lookup.
319
- # Default: 'datagrid'.
320
- #
308
+ # @option options [Array<Symbol>] columns An array of column names to display.
309
+ # Use this when the same grid class is used in different contexts and requires different columns.
310
+ # Default: all defined columns.
311
+ # @option options [String] partials The path for partials lookup.
312
+ # Default: `'datagrid'`.
321
313
# @return [String]
322
- # @example
323
- # = datagrid_rows(grid) # Generic table rows Layout
324
- #
325
- # = datagrid_rows(grid) do |row| # Custom Layout
314
+ # @example Generic table rows Layout
315
+ # = datagrid_rows(grid)
316
+ # @example Custom Layout
317
+ # = datagrid_rows(grid) do |row|
326
318
# %tr
327
319
# %td= row.project_name
328
320
# %td.project-status{class: row.status}= row.status
@@ -331,11 +323,8 @@ def datagrid_rows(grid, assets = grid.assets, **options, &block)
331
323
end
332
324
333
325
# @return [String] renders ordering controls for the given column name
334
- #
335
- # Supported options:
336
- #
337
- # * <tt>:partials</tt> - Path for partials lookup.
338
- # Default: 'datagrid'.
326
+ # @option options [String] partials The path for partials lookup.
327
+ # Default: `'datagrid'`.
339
328
def datagrid_order_for ( grid , column , options = { } )
340
329
datagrid_renderer . order_for ( grid , column , options )
341
330
end
@@ -361,20 +350,19 @@ def datagrid_form_for(grid, options = {})
361
350
# @param block [Proc] block with Datagrid::Helper::HtmlRow as an argument returning a HTML markup as a String
362
351
# @param [Hash{Symbol => Object}] options
363
352
# @return [Datagrid::Helper::HtmlRow, String] captured HTML markup if block given otherwise row object
364
- # @example
365
- # # Suppose that grid has first_name and last_name columns
353
+ # @example Render default layout for row
354
+ # <%= datagrid_row(grid, user, columns: [:first_name, :last_name, :actions]) %>
355
+ # @example Rendering custom layout for `first_name` and `last_name` columns
366
356
# <%= datagrid_row(grid, user) do |row| %>
367
357
# <tr>
368
358
# <td><%= row.first_name %></td>
369
359
# <td><%= row.last_name %></td>
370
360
# </tr>
371
361
# <% end %>
372
- # @example
362
+ # @example Rendering custom layout passing a block
373
363
# <% row = datagrid_row(grid, user) %>
374
364
# First Name: <%= row.first_name %>
375
365
# Last Name: <%= row.last_name %>
376
- # @example
377
- # <%= datagrid_row(grid, user, columns: [:first_name, :last_name, :actions]) %>
378
366
def datagrid_row ( grid , asset , **options , &block )
379
367
datagrid_renderer . row ( grid , asset , **options , &block )
380
368
end
0 commit comments