Method: Datagrid::Helper#datagrid_header

Defined in:
lib/datagrid/helper.rb

#datagrid_header(grid, opts = :__unspecified__, **options) ⇒ String

Renders HTML table header for given grid instance using columns defined in it

Parameters:

  • grid (Datagrid::Base)

    grid object

  • opts (Object) (defaults to: :__unspecified__)

    (deprecated) pass keyword arguments instead

  • options (Hash)

Options Hash (**options):

  • order (Boolean)

    Whether to display ordering controls built into the header. Default: true.

  • columns (Array<Symbol,String>)

    An array of column names to display. Use this when the same grid class is used in different contexts and requires different columns. Default: all defined columns.

  • partials (String)

    The path for partials lookup. Default: 'datagrid'.

Returns:

  • (String)

    HTML table header tag markup


307
308
309
310
311
312
313
314
315
316
# File 'lib/datagrid/helper.rb', line 307

def datagrid_header(grid, opts = :__unspecified__, **options)
  unless opts == :__unspecified__
    Datagrid::Utils.warn_once("datagrid_header now requires ** operator when passing options.")
    options.reverse_merge!(opts)
  end
  options[:order] = true unless options.key?(:order)

  _render_partial("head", options[:partials],
    { grid: grid, options: options },)
end