Flop.Phoenix.table

You're seeing just the function table, go back to Flop.Phoenix module for more information.
Link to this function

table(assigns)

View Source (since 0.6.0)

Specs

Generates a table with sortable columns.

The argument is a map with the following keys:

  • headers: A list of header columns. Can be a list of strings (or markup), or a list of {value, field_name} tuples.
  • items: The list of items to be displayed in rows. This is the result list returned by the query.
  • meta: The Flop.Meta struct returned by the query function.
  • path_helper: The Phoenix path or url helper that leads to the current page.
  • path_helper_args: The argument list for the path helper. For example, if you would call Routes.pet_path(@conn, :index) to generate the path for the current page, this would be [@conn, :index].
  • opts: Keyword list with additional options (see below). This list will also be passed as the second argument to the row function.
  • row_func: A function that takes one item of the items list and the opts and returns the column values for that item's row.

Available options

  • :for - The schema module deriving Flop.Schema. If set, header links are only added for fields that are defined as sortable. Default: nil.
  • :table_attrs - The attributes for the <table> element. Default: [].
  • :th_wrapper_attrs - The attributes for the <span> element that wraps the header link and the order direction symbol. Default: [].
  • :symbol_attrs - The attributes for the <span> element that wraps the order direction indicator in the header columns. Default: [class: "order-direction"].
  • :symbol_asc - The symbol that is used to indicate that the column is sorted in ascending order. Default: "▴".
  • :symbol_desc - The symbol that is used to indicate that the column is sorted in ascending order. Default: "▾".
  • :container - Wraps the table in a <div> if true. Default: false.
  • :container_attrs - The attributes for the table container. Default: [class: "table-container"].
  • :no_results_content - Any content that should be rendered if there are no results. Default: <p>No results.</p>.
  • :thead_tr_attrs: Attributes to added to each <tr> tag within the <thead>. Default: [].
  • :thead_th_attrs: Attributes to added to each <th> tag within the <thead>. Default: [].
  • :tbody_tr_attrs: Attributes to added to each <tr> tag within the <tbody>. Default: [].
  • :tbody_td_attrs: Attributes to added to each <td> tag within the <tbody>. Default: [].

See the module documentation for examples.