egui_data_table::viewer

Trait RowViewer

Source
pub trait RowViewer<R>: 'static {
Show 23 methods // Required methods fn num_columns(&mut self) -> usize; fn show_cell_view(&mut self, ui: &mut Ui, row: &R, column: usize); fn show_cell_editor( &mut self, ui: &mut Ui, row: &mut R, column: usize, ) -> Option<Response>; fn set_cell_value(&mut self, src: &R, dst: &mut R, column: usize); fn new_empty_row(&mut self) -> R; // Provided methods fn column_name(&mut self, column: usize) -> Cow<'static, str> { ... } fn try_create_codec( &mut self, is_encoding: bool, ) -> Option<impl RowCodec<R>> { ... } fn column_render_config(&mut self, column: usize) -> TableColumnConfig { ... } fn is_sortable_column(&mut self, column: usize) -> bool { ... } fn compare_cell(&self, row_a: &R, row_b: &R, column: usize) -> Ordering { ... } fn row_filter_hash(&mut self) -> &impl Hash { ... } fn filter_row(&mut self, row: &R) -> bool { ... } fn on_cell_view_response( &mut self, row: &R, column: usize, resp: &Response, ) -> Option<Box<R>> { ... } fn confirm_cell_write_by_ui( &mut self, current: &R, next: &R, column: usize, context: CellWriteContext, ) -> bool { ... } fn confirm_row_deletion_by_ui(&mut self, row: &R) -> bool { ... } fn new_empty_row_for(&mut self, context: EmptyRowCreateContext) -> R { ... } fn clone_row(&mut self, row: &R) -> R { ... } fn clone_row_for_insertion(&mut self, row: &R) -> R { ... } fn clone_row_as_copied_base(&mut self, row: &R) -> R { ... } fn on_highlight_cell(&mut self, row: &R, column: usize) { ... } fn hotkeys( &mut self, context: &UiActionContext, ) -> Vec<(KeyboardShortcut, UiAction)> { ... } fn trivial_config(&mut self) -> TrivialConfig { ... } fn persist_ui_state(&self) -> bool { ... }
}
Expand description

The primary trait for the spreadsheet viewer.

Required Methods§

Source

fn num_columns(&mut self) -> usize

Number of columns. Changing this will invalidate the table rendering status totally(including undo histories), therefore frequently changing this value is discouraged.

Source

fn show_cell_view(&mut self, ui: &mut Ui, row: &R, column: usize)

Display values of the cell. Any input will be consumed before table renderer; therefore any widget rendered inside here is read-only.

To deal with input, use cell_edit method. If you need to deal with drag/drop, see RowViewer::on_cell_view_response which delivers resulting response of containing cell.

Source

fn show_cell_editor( &mut self, ui: &mut Ui, row: &mut R, column: usize, ) -> Option<Response>

Edit values of the cell.

Source

fn set_cell_value(&mut self, src: &R, dst: &mut R, column: usize)

Set the value of a column in a row.

Source

fn new_empty_row(&mut self) -> R

Create a new empty row.

Provided Methods§

Source

fn column_name(&mut self, column: usize) -> Cow<'static, str>

Name of the column. This can be dynamically changed.

Source

fn try_create_codec(&mut self, is_encoding: bool) -> Option<impl RowCodec<R>>

Tries to create a codec for the row (de)serialization. If this returns Some, it’ll use the system clipboard for copy/paste operations.

is_encoding parameter is provided to determine if we’re creating the codec as encoding mode or decoding mode.

It is just okay to choose not to implement both encoding and decoding; returning None conditionally based on is_encoding parameter is also valid. It is guaranteed that created codec will be used only for the same mode during its lifetime.

Source

fn column_render_config(&mut self, column: usize) -> TableColumnConfig

Returns the rendering configuration for the column.

Source

fn is_sortable_column(&mut self, column: usize) -> bool

Returns if given column is ‘sortable’

Source

fn compare_cell(&self, row_a: &R, row_b: &R, column: usize) -> Ordering

Compare two column contents for sort.

Source

fn row_filter_hash(&mut self) -> &impl Hash

Get hash value of a filter. This is used to determine if the filter has changed.

Source

fn filter_row(&mut self, row: &R) -> bool

Filter single row. If this returns false, the row will be hidden.

Source

fn on_cell_view_response( &mut self, row: &R, column: usize, resp: &Response, ) -> Option<Box<R>>

Use this to check if given cell is going to take any dropped payload / use as drag source.

Source

fn confirm_cell_write_by_ui( &mut self, current: &R, next: &R, column: usize, context: CellWriteContext, ) -> bool

In the write context that happens outside of show_cell_editor, this method is called on every cell value editions.

Source

fn confirm_row_deletion_by_ui(&mut self, row: &R) -> bool

Before removing each row, this method is called to confirm the deletion from the viewer. This won’t be called during the undo/redo operation!

Source

fn new_empty_row_for(&mut self, context: EmptyRowCreateContext) -> R

Create a new empty row under the given context.

Source

fn clone_row(&mut self, row: &R) -> R

Create duplication of existing row.

You may want to override this method for more efficient duplication.

Source

fn clone_row_for_insertion(&mut self, row: &R) -> R

Create duplication of existing row for insertion.

Source

fn clone_row_as_copied_base(&mut self, row: &R) -> R

Create duplication of existing row for clipboard. Useful when you need to specify different behavior for clipboard duplication. (e.g. unset transient flag)

Source

fn on_highlight_cell(&mut self, row: &R, column: usize)

Called when a cell is selected/highlighted.

Source

fn hotkeys( &mut self, context: &UiActionContext, ) -> Vec<(KeyboardShortcut, UiAction)>

Return hotkeys for the current context.

Source

fn trivial_config(&mut self) -> TrivialConfig

Get trivial configurations for renderer.

Source

fn persist_ui_state(&self) -> bool

If you want to keep UI state on storage(i.e. persist over sessions), return true from this function.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§