Trait ColumnOperations

Source
pub trait ColumnOperations<Row, F, Conf>
where Row: Clone + Send + Sync, F: Eq + Hash + Clone + Ord + Send + Sync + Default + ColumnOperations<Row, F, Conf> + ColumnOrdering<Row>, Conf: Default,
{ // Required methods fn create_header( &self, ui: &mut Ui, sort_order: Option<SortOrder>, table: &mut SelectableTable<Row, F, Conf>, ) -> Option<Response>; fn create_table_row( &self, ui: &mut Ui, row: &SelectableRow<Row, F>, column_selected: bool, table: &mut SelectableTable<Row, F, Conf>, ) -> Response; fn column_text(&self, row: &Row) -> String; }
Expand description

Trait for defining column-specific operations in a table UI.

This trait allows users to define how each column should behave within a table. This includes how headers should be displayed, how each row in the table should be rendered, and how to extract column-specific text.

§Type Parameters:

  • Row - The type representing each row in the table.
  • F - A type that identifies columns, usually an enum or a field type.
  • Conf - Configuration type for the table, useful for passing additional settings.

§Requirements:

You must implement this trait to specify the behavior of each column within the context of your table UI.

Required Methods§

Source

fn create_header( &self, ui: &mut Ui, sort_order: Option<SortOrder>, table: &mut SelectableTable<Row, F, Conf>, ) -> Option<Response>

Create the header UI for this column.

This function is responsible for creating the visual representation of the column header. The sort_order argument indicates whether the column is currently used for sorting and, if so, in which direction (ascending or descending). You can customize the header appearance based on this information, for example by adding icons or text. Return None for no header.

§Arguments
  • ui - A mutable reference to the UI context.
  • sort_order - An optional SortOrder representing the current sort state of the column.
  • table - A mutable reference to the SelectableTable, allowing you to interact with the table state.
§Returns
  • Option<Response> - An optional response representing interaction with the UI.
Source

fn create_table_row( &self, ui: &mut Ui, row: &SelectableRow<Row, F>, column_selected: bool, table: &mut SelectableTable<Row, F, Conf>, ) -> Response

Create the UI for a specific row in this column.

This function is responsible for rendering the content of this column for a given row. It should handle user interactions like clicking or selection as necessary. Mutable table access is provided for modifyiing other rows as necessary.

§Arguments
  • ui - A mutable reference to the UI context.
  • row - A reference to the current SelectableRow for this table.
  • column_selected - A boolean indicating whether this column is selected.
  • table - A mutable reference to the SelectableTable for modifying table data
§Returns
  • Response - The result of the UI interaction for this row.
Source

fn column_text(&self, row: &Row) -> String

Extract the text representation of the column for the given row.

This function should return the appropriate text representation of this column for the given row. It can be used to display the data in a simplified form, such as for debugging or plain text rendering.

§Arguments
  • row - A reference to the row from which to extract the column text.
§Returns
  • String - The text representation of this column for the row.

Implementors§