Method: Datagrid::Helper#datagrid_table

Defined in:
lib/datagrid/helper.rb

#datagrid_table(grid, assets = grid.assets, **options) ⇒ String

Renders html table with columns defined in grid class. In the most common used you need to pass paginated collection to datagrid table because datagrid do not have pagination compatibilities:

Examples:

assets = grid.assets.page(params[:page])
datagrid_table(grid, assets, options)

Parameters:

  • grid (Datagrid::Base)

    grid object

  • assets (Array) (defaults to: grid.assets)

    objects from grid scope

  • options (Hash{Symbol => Object})

    HTML attributes to be passed to <table> tag

Options Hash (**options):

  • html (Hash)

    A hash of attributes for the <table> tag.

  • order (Boolean)

    Whether to generate ordering controls. If set to false, ordering controls are not generated. Default: true.

  • columns (Array<Symbol>)

    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)

    table tag HTML markup


283
284
285
286
287
288
289
290
291
292
# File 'lib/datagrid/helper.rb', line 283

def datagrid_table(grid, assets = grid.assets, **options)
  _render_partial(
    "table", options[:partials],
    {
      grid: grid,
      options: options,
      assets: assets,
    },
  )
end