Trait egui_data_table::viewer::RowViewer
source · pub trait RowViewer<R>: 'static {
Show 22 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 column_render_config(&mut self, column: usize) -> TableColumnConfig { ... }
fn is_sortable_column(&mut self, column: usize) -> bool { ... }
fn create_cell_comparator(&mut self) -> impl Fn(&R, &R, usize) -> Ordering { ... }
fn row_filter_hash(&mut self) -> &impl Hash { ... }
fn create_row_filter(&mut self) -> impl Fn(&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§
sourcefn num_columns(&mut self) -> usize
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.
sourcefn show_cell_view(&mut self, ui: &mut Ui, row: &R, column: usize)
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.
sourcefn show_cell_editor(
&mut self,
ui: &mut Ui,
row: &mut R,
column: usize
) -> Option<Response>
fn show_cell_editor( &mut self, ui: &mut Ui, row: &mut R, column: usize ) -> Option<Response>
Edit values of the cell.
sourcefn set_cell_value(&mut self, src: &R, dst: &mut R, column: usize)
fn set_cell_value(&mut self, src: &R, dst: &mut R, column: usize)
Set the value of a column in a row.
sourcefn new_empty_row(&mut self) -> R
fn new_empty_row(&mut self) -> R
Create a new empty row.
Provided Methods§
sourcefn column_name(&mut self, column: usize) -> Cow<'static, str>
fn column_name(&mut self, column: usize) -> Cow<'static, str>
Name of the column. This can be dynamically changed.
sourcefn column_render_config(&mut self, column: usize) -> TableColumnConfig
fn column_render_config(&mut self, column: usize) -> TableColumnConfig
Returns the rendering configuration for the column.
sourcefn is_sortable_column(&mut self, column: usize) -> bool
fn is_sortable_column(&mut self, column: usize) -> bool
Returns if given column is ‘sortable’
sourcefn create_cell_comparator(&mut self) -> impl Fn(&R, &R, usize) -> Ordering
fn create_cell_comparator(&mut self) -> impl Fn(&R, &R, usize) -> Ordering
Compare two column contents for sort.
sourcefn row_filter_hash(&mut self) -> &impl Hash
fn row_filter_hash(&mut self) -> &impl Hash
Get hash value of a filter. This is used to determine if the filter has changed.
sourcefn create_row_filter(&mut self) -> impl Fn(&R) -> bool
fn create_row_filter(&mut self) -> impl Fn(&R) -> bool
Create a filter for the row. Filter is applied on every table invalidation.
sourcefn on_cell_view_response(
&mut self,
row: &R,
column: usize,
resp: &Response
) -> Option<Box<R>>
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.
sourcefn confirm_cell_write_by_ui(
&mut self,
current: &R,
next: &R,
column: usize,
context: CellWriteContext
) -> bool
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.
sourcefn confirm_row_deletion_by_ui(&mut self, row: &R) -> bool
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!
sourcefn new_empty_row_for(&mut self, context: EmptyRowCreateContext) -> R
fn new_empty_row_for(&mut self, context: EmptyRowCreateContext) -> R
Create a new empty row under the given context.
sourcefn clone_row(&mut self, row: &R) -> R
fn clone_row(&mut self, row: &R) -> R
Create duplication of existing row.
You may want to override this method for more efficient duplication.
sourcefn clone_row_for_insertion(&mut self, row: &R) -> R
fn clone_row_for_insertion(&mut self, row: &R) -> R
Create duplication of existing row for insertion.
sourcefn clone_row_as_copied_base(&mut self, row: &R) -> R
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)
sourcefn on_highlight_cell(&mut self, row: &R, column: usize)
fn on_highlight_cell(&mut self, row: &R, column: usize)
Called when a cell is selected/highlighted.
sourcefn hotkeys(
&mut self,
context: &UiActionContext
) -> Vec<(KeyboardShortcut, UiAction)>
fn hotkeys( &mut self, context: &UiActionContext ) -> Vec<(KeyboardShortcut, UiAction)>
Return hotkeys for the current context.
sourcefn trivial_config(&mut self) -> TrivialConfig
fn trivial_config(&mut self) -> TrivialConfig
Get trivial configurations for renderer.
sourcefn persist_ui_state(&self) -> bool
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.