ExLiveTable.DataTable (ExLiveTable v0.1.0)
View SourceProvides helper functions for table sorting, pagination, and query string operations.
Summary
Functions
Handles the empty table state, displaying a loading spinner or "No data" message.
Renders a search input box that triggers an "iSearch" event on change.
Builds a query string from the current params and options. Used for pagination and sorting links.
Parses sort parameters from URL query parameters. Returns a tuple of {sort_direction, sort_field}.
Creates a table header link for sorting with proper direction switching.
Functions
Handles the empty table state, displaying a loading spinner or "No data" message.
Attributes
data_loader
(:boolean
) - Defaults totrue
.
Renders a search input box that triggers an "iSearch" event on change.
Attributes
params
(:map
) - Defaults to%{"filter" => %{"isearch" => ""}}
.
Builds a query string from the current params and options. Used for pagination and sorting links.
Examples
iex> querystring(%{"page" => "1"}, sort_field: :name, sort_direction: "desc")
"page=1&sort_field=name&sort_direction=desc"
Parses sort parameters from URL query parameters. Returns a tuple of {sort_direction, sort_field}.
Examples
iex> sort(%{"sort_field" => "name", "sort_direction" => "asc"})
{:asc, :name}
iex> sort(%{"sort_field" => "created_at", "sort_direction" => "desc"})
{:desc, :created_at}
iex> sort(%{})
{:asc, :id}
Creates a table header link for sorting with proper direction switching.
Examples
iex> table_link(%{"sort_field" => "name", "sort_direction" => "asc"}, "Name", :name)
# Returns a LiveView link to sort by name in desc order