#[non_exhaustive]pub struct Column { /* private fields */ }Implementations§
Source§impl Column
impl Column
A value of the row this one belongs to: table’s column where its
id is this row’s foreign_key
(Column::related("customer", "Customer", "customers", "customer_id", "name")).
Shown, sorted, filtered and searched like a text column (.numeric()
for a number), in one query per page.
Sourcepub fn count_of(key: &str, label: &str, table: &str, foreign_key: &str) -> Self
pub fn count_of(key: &str, label: &str, table: &str, foreign_key: &str) -> Self
How many rows of table point at this row through foreign_key
(Column::count_of("notes", "Notes", "order_notes", "order_id")).
Sourcepub fn sum_of(
key: &str,
label: &str,
table: &str,
foreign_key: &str,
column: &str,
) -> Self
pub fn sum_of( key: &str, label: &str, table: &str, foreign_key: &str, column: &str, ) -> Self
The total of column over the rows of table that point at this
row through foreign_key.
Sourcepub fn computed(self, sql: &str) -> Self
pub fn computed(self, sql: &str) -> Self
The column’s value is sql, a scalar SQL expression over the row,
where {T} stands for the model’s table: stock value as
Column::money("value", "Value").computed("{T}.\"on_hand\" * (SELECT \"cost\" FROM \"variants\" WHERE \"id\" = {T}.\"variant_id\")").
It is shown, sorted, filtered, searched, summed (Column::summary)
and grouped by (Grid::groups) like a related column, with no
database view. sql is written by the app, never taken from a
request: values go in the model’s columns and subqueries, not in
the string.
Sourcepub fn image(key: &str, label: &str) -> Self
pub fn image(key: &str, label: &str) -> Self
An image column: the value is the image’s URL (.round() for
avatars).
Sourcepub fn color(key: &str, label: &str) -> Self
pub fn color(key: &str, label: &str) -> Self
A color column: a swatch of the CSS color in the value, with its code.
Sourcepub fn badges(self, tones: &[(&str, &str)]) -> Self
pub fn badges(self, tones: &[(&str, &str)]) -> Self
Values as colored badges: (value, tone) pairs, the tone one of
success, warning, danger, info or neutral. Values not
listed get a neutral badge; .badges(&[]) makes every value one.
Sourcepub fn description(self, key: &str) -> Self
pub fn description(self, key: &str) -> Self
Another of the row’s values, small under this one (an email under a name).
Sourcepub fn tooltip(self, key: &str) -> Self
pub fn tooltip(self, key: &str) -> Self
Another of the row’s values, shown when the cell is hovered.
Sourcepub fn limit(self, chars: usize) -> Self
pub fn limit(self, chars: usize) -> Self
Text past chars characters is cut with … (the whole text shows on
hover).
Sourcepub fn number(key: &str, label: &str) -> Self
pub fn number(key: &str, label: &str) -> Self
A number column (.decimals(n) for a fixed number of decimals).
Sourcepub fn money(key: &str, label: &str) -> Self
pub fn money(key: &str, label: &str) -> Self
An amount in the smallest unit (cents, fils), shown in whole units
of APP_CURRENCY with its usual decimals (129900 cents is
1,299.00 in USD, 400,000 in IDR), as the money template filter
takes it. Summaries and exports show whole units too,
and range filters take them. An inline edit still sends the stored
value (the smallest unit).
Sourcepub fn datetime(key: &str, label: &str) -> Self
pub fn datetime(key: &str, label: &str) -> Self
A date and time column (shown in APP_TIMEZONE).
Sourcepub fn select<V: Into<String>, L: Into<String>>(
key: &str,
label: &str,
options: impl IntoIterator<Item = (V, L)>,
) -> Self
pub fn select<V: Into<String>, L: Into<String>>( key: &str, label: &str, options: impl IntoIterator<Item = (V, L)>, ) -> Self
One of options (stored value, label shown).
Several of options, stored as a JSON array of the values.
Sourcepub fn custom(key: &str, label: &str) -> Self
pub fn custom(key: &str, label: &str) -> Self
A column the page’s template draws ({% call(row, column) grid(…) %}).
key needn’t be a database column.
Sourcepub fn under<S: Into<String>>(self, groups: impl IntoIterator<Item = S>) -> Self
pub fn under<S: Into<String>>(self, groups: impl IntoIterator<Item = S>) -> Self
Puts the column under grouped headings, outermost first:
.under(["Amounts"]), .under(["Sales", "Q1"]). Neighbouring
columns under the same headings share them.
Sourcepub fn sortable(self, sortable: bool) -> Self
pub fn sortable(self, sortable: bool) -> Self
Whether a click on the heading sorts by this column (default: yes, except for tags and custom columns).
Sourcepub fn filterable(self, filterable: bool) -> Self
pub fn filterable(self, filterable: bool) -> Self
Whether the heading has a filter (default: yes, except for custom columns).
Sourcepub fn mobile(self) -> Self
pub fn mobile(self) -> Self
Shown on small screens until the user picks otherwise. When no column says so, the first three are.
Hidden on wide screens too until the user turns it on.
Sourcepub fn frozen_right(self) -> Self
pub fn frozen_right(self) -> Self
Frozen at the right edge (e.g. a column of actions).
Sourcepub fn editable(self) -> Self
pub fn editable(self) -> Self
Cells can be edited in place (double-click, Enter or F2; Enter saves,
Escape cancels) and in the row’s edit mode. Saving sends the value
to the grid’s Grid::edit_url. Not for custom columns, nor for
merged ones.
Sourcepub fn merge(self) -> Self
pub fn merge(self) -> Self
Neighbouring rows with the same value share one cell. Merged columns nest from left to right: a column merges only within the merged groups of the merged columns before it (Region, then City). Merging is off while rows are dragged into order.
Sourcepub fn searchable(self) -> Self
pub fn searchable(self) -> Self
The toolbar’s search box looks in this column (as text, ignoring case). The box shows when a column is searchable. Not for custom columns.
When the grid’s model has a full-text index (#[model(search = …)],
see renox::db::search), the box searches
through it instead: every column of the index counts (also those the
grid doesn’t show), words match their other forms and prefixes, and
rows come best match first until the user sorts. Searchable columns
outside the index are still matched as text.
Sourcepub fn summary(self, summary: Summary) -> Self
pub fn summary(self, summary: Summary) -> Self
A figure over every row the filters match, in the grid’s footer and
under each group: .summary(Summary::Sum), several in a row
(.summary(Summary::Sum).summary(Summary::Average)). Sum, average
and range are for number and money columns; count for any.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Column
impl RefUnwindSafe for Column
impl Send for Column
impl Sync for Column
impl Unpin for Column
impl UnsafeUnpin for Column
impl UnwindSafe for Column
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more