PhoenixFilament.Widget.Table behaviour (PhoenixFilament v0.1.0)

Copy Markdown View Source

A widget that displays a simple read-only table on the dashboard.

Summary

Callbacks

Optional callback to provide an Ecto query for fetching rows.

Callbacks

columns()

@callback columns() :: [PhoenixFilament.Column.t()]

heading()

@callback heading() :: String.t()

query()

(optional)
@callback query() :: Ecto.Query.t()

Optional callback to provide an Ecto query for fetching rows.

When implemented, your widget's update/2 override should execute the query against your Repo and assign the results to the :rows assign. Example:

def update(assigns, socket) do
  {:ok, socket} = super(assigns, socket)
  rows = MyApp.Repo.all(query())
  {:ok, Phoenix.Component.assign(socket, :rows, rows)}
end

Functions

render(assigns)