Skip to main content

ColumnDef

Struct ColumnDef 

Source
pub struct ColumnDef<T> {
    pub meta: ColumnMeta,
    pub accessor: Option<DataTableDynAccessor<T>>,
    pub sorting_fn: Option<SortingFn<T>>,
    pub filter_fn: Option<FilterFn<T>>,
    pub aggregation_fn: Option<AggregationFn<T>>,
    pub columns: Vec<ColumnDef<T>>,
    pub enable_multi_sort: bool,
    pub invert_sorting: bool,
    pub sort_undefined_last: bool,
}
Expand description

Definition of a table column.

ColumnDef is generic over the row data type T and provides all configuration needed to display and interact with a column.

Fields§

§meta: ColumnMeta

Column metadata (ID, header, footer, etc.).

§accessor: Option<DataTableDynAccessor<T>>

Accessor function to get the cell value from row data.

§sorting_fn: Option<SortingFn<T>>

Custom sorting function.

§filter_fn: Option<FilterFn<T>>

Custom filter function.

§aggregation_fn: Option<AggregationFn<T>>

Aggregation function for grouped rows.

§columns: Vec<ColumnDef<T>>

Child columns for grouped columns.

§enable_multi_sort: bool

Enable multi-sorting for this column.

§invert_sorting: bool

Invert the sort direction.

§sort_undefined_last: bool

Sort undefined values to the end.

Implementations§

Source§

impl<T> ColumnDef<T>

Source

pub fn new(id: impl Into<ColumnId>, header: impl Into<String>) -> Self

Creates a new column definition with the given ID and header.

§Parameters
  • id: The column identifier.
  • header: The display header text.
§Returns
  • ColumnDef<T>: A new column definition with default settings.
Source

pub fn group( id: impl Into<ColumnId>, header: impl Into<String>, columns: Vec<ColumnDef<T>>, ) -> Self

Creates a group column with child columns.

§Parameters
  • id: The column identifier.
  • header: The display header text.
  • columns: The child column definitions.
§Returns
  • ColumnDef<T>: A new group column definition.
Source

pub fn id(&self) -> &ColumnId

Returns the column ID.

§Returns
  • &ColumnId: A reference to the column identifier.
Source

pub fn header(&self) -> &str

Returns the column header text.

§Returns
  • &str: The column header text.
Source

pub fn is_sortable(&self) -> bool

Returns whether this column is sortable.

§Returns
  • bool: Whether sorting is enabled for this column.
Source

pub fn is_filterable(&self) -> bool

Returns whether this column is filterable.

§Returns
  • bool: Whether filtering is enabled for this column.
Source

pub fn is_group(&self) -> bool

Returns whether this column is a group column.

§Returns
  • bool: Whether this is a group column containing sub-columns.
Source

pub fn children(&self) -> &[ColumnDef<T>]

Returns the child columns for group columns.

§Returns
  • &[ColumnDef<T>]: A slice of child column definitions.
Source

pub fn get_value(&self, row: &T) -> Option<Box<dyn DataTableDynValue>>

Gets the value from the row using the accessor.

§Parameters
  • row: The row data to extract the value from.
§Returns
  • Option<Box<dyn DataTableDynValue>>: The extracted value, or None if no accessor is set.
Source

pub fn flatten(&self) -> Vec<&ColumnDef<T>>

Flattens the column hierarchy into a list of leaf columns.

§Returns
  • Vec<&ColumnDef<T>>: A vector of references to leaf columns.
Source

pub fn all_ids(&self) -> Vec<ColumnId>

Returns all column IDs including nested columns.

§Returns
  • Vec<ColumnId>: A vector of all column IDs in the hierarchy.

Trait Implementations§

Source§

impl<T> Debug for ColumnDef<T>

Formats the column definition for debug output.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for ColumnDef<T>

§

impl<T> !RefUnwindSafe for ColumnDef<T>

§

impl<T> Send for ColumnDef<T>

§

impl<T> Sync for ColumnDef<T>

§

impl<T> Unpin for ColumnDef<T>

§

impl<T> UnsafeUnpin for ColumnDef<T>

§

impl<T> !UnwindSafe for ColumnDef<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.