PetalComponents.DataTable.Engine.List (petal_components v4.12.0)

Copy Markdown View Source

The in-memory engine: sort, filter and paginate a plain list of maps or structs against a PetalComponents.DataTable.State.

This is the zero-setup path - the registry examples, the playground and any app with an already-loaded list get a working table with no database and no extra dependency. It is deliberately a toy for data that fits in memory; real query backends (Ecto/Flop adapters, cursor pagination) are the production wiring layer, not this module.

{rows, state} = Engine.List.run(all_rows, state)

returns the visible page plus the state with total filled in (the post-filter count), which is what the footer and pagination render from.

Filter semantics by operator - all string comparisons are case-insensitive, nil field values never match:

  • :contains, :starts_with, :eq on strings
  • :eq, :neq, :gt, :lt numeric (value coerced from string)
  • :between with a [min, max] (or %{"min" => _, "max" => _}) value
  • :in with a list value (select/enum filters)
  • :before, :on, :after on Date/DateTime/ISO8601 strings

Summary

Functions

Runs the full pipeline: filter -> sort -> count -> paginate.

Functions

run(rows, state)

Runs the full pipeline: filter -> sort -> count -> paginate.