pub struct DataGrid { /* private fields */ }Expand description
A virtualized data grid in the spirit of enterprise grids: sorting by one or
several columns, a filter row with operators and filters by value, a search panel,
grouping by dragging columns to the group panel, group summaries, footer totals,
columns to resize, reorder, pin and hide, a menu on each column, single or multiple
selection, keyboard navigation, in-place editing, cell templates, CSV export, pages,
saved scenarios, and rows that stay on a server (DataGrid::remote). Only the
visible rows are built, so 100,000+ rows stay smooth.
use ravenrs_widgets::{DataGrid, GridColumn, GridData, SortDirection, Summary, Ui};
let data = GridData::new(vec![
vec!["Acme".into(), 1200.0.into()],
vec!["Globex".into(), 860.5.into()],
]);
let grid = DataGrid::new(
data,
[GridColumn::text("Customer"), GridColumn::currency("MRR", "$", 2).summary(Summary::Sum)],
)
.sort_by(1, SortDirection::Descending)
.height(320.0);
let mut ui = Ui::new(grid, ravenrs_style::Theme::raven_dark());
ui.update();Implementations§
Source§impl DataGrid
impl DataGrid
Sourcepub fn empty_text(self, text: impl Into<String>) -> DataGrid
pub fn empty_text(self, text: impl Into<String>) -> DataGrid
What it says when there is no data at all, as opposed to filters leaving nothing.
Sourcepub fn new(
data: GridData,
columns: impl IntoIterator<Item = GridColumn>,
) -> DataGrid
pub fn new( data: GridData, columns: impl IntoIterator<Item = GridColumn>, ) -> DataGrid
A grid over data with these columns; single selection, filter row, toolbar and footer on.
Sourcepub fn name_column(self, column: usize) -> DataGrid
pub fn name_column(self, column: usize) -> DataGrid
The column whose cell names a row for screen readers, in the buttons of
row_action. The key column, or else the first, by default.
Sourcepub fn cell_style(
self,
style: impl Fn(&Vec<Value>, usize) -> GridCellStyle + 'static,
) -> DataGrid
pub fn cell_style( self, style: impl Fn(&Vec<Value>, usize) -> GridCellStyle + 'static, ) -> DataGrid
Decides how each cell looks, from its row and its column.
Sourcepub fn filter_builder(self, show: bool) -> DataGrid
pub fn filter_builder(self, show: bool) -> DataGrid
Shows a Filter button in the toolbar that opens a FilterBuilder
over the columns. What it writes is an expression, kept with the filters of
the filter row, so it goes in saved scenarios and comes out with Clear.
Sourcepub fn row_detail(
self,
detail: impl Fn(&Vec<Value>, usize) -> Box<dyn View> + 'static,
) -> DataGrid
pub fn row_detail( self, detail: impl Fn(&Vec<Value>, usize) -> Box<dyn View> + 'static, ) -> DataGrid
Gives every row details of its own, opened by an arrow at its start or with the Right key: a nested list, a form, a chart. The view is built only while it is open, with the row and its index in the data.
Sourcepub fn detail_height(self, height: f32) -> DataGrid
pub fn detail_height(self, height: f32) -> DataGrid
The height of a row’s details in logical pixels. 240 by default.
Sourcepub fn expanded_rows(self, rows: Binding<BTreeSet<usize>>) -> DataGrid
pub fn expanded_rows(self, rows: Binding<BTreeSet<usize>>) -> DataGrid
The rows with details open, by index in the data, to keep or to set from outside.
Sourcepub fn on_export_file(
self,
handler: impl Fn(GridExportFormat, GridTable) + 'static,
) -> DataGrid
pub fn on_export_file( self, handler: impl Fn(GridExportFormat, GridTable) + 'static, ) -> DataGrid
Shows an Export menu with Excel, PDF and CSV; handler receives the format and the rows
that match, as shown. ravenrs-grid-export turns these into a file.
Sourcepub fn export_title(self, title: impl Into<String>) -> DataGrid
pub fn export_title(self, title: impl Into<String>) -> DataGrid
The title of the files the Export menu makes. The grid’s name by default.
Sourcepub fn remote(
rows: RemoteRows,
columns: impl IntoIterator<Item = GridColumn>,
) -> DataGrid
pub fn remote( rows: RemoteRows, columns: impl IntoIterator<Item = GridColumn>, ) -> DataGrid
A grid over rows that stay on a server. It asks for what is on the screen, keeps
a limited number of rows, and sorting, filtering and searching are up to the
loader. It scrolls on as rows arrive, or in pages with
page_size; grouping needs the rows at hand, so it is off.
Sourcepub fn page_size(self, rows: usize) -> DataGrid
pub fn page_size(self, rows: usize) -> DataGrid
Shows the rows a page at a time, with a pager at the bottom.
Sourcepub fn group_panel(self, show: bool) -> DataGrid
pub fn group_panel(self, show: bool) -> DataGrid
Shows or hides the space where columns are dropped to group by them. It shows along with the toolbar, unless this says otherwise.
Sourcepub fn vertical_lines(self, show: bool) -> DataGrid
pub fn vertical_lines(self, show: bool) -> DataGrid
Draws a line between columns.
Sourcepub fn layout(self, layout: Binding<GridLayout>) -> DataGrid
pub fn layout(self, layout: Binding<GridLayout>) -> DataGrid
Where its arrangement lives: read when it changes, and written when someone moves something. Keep this to bring it back as it was.
Sourcepub fn scenarios(self, scenarios: Binding<Vec<GridScenario>>) -> DataGrid
pub fn scenarios(self, scenarios: Binding<Vec<GridScenario>>) -> DataGrid
Offers saving its arrangement under a name and coming back to it. Keep the list
with GridScenario::list_to_json.
Sourcepub fn selection_mode(self, mode: SelectionMode) -> DataGrid
pub fn selection_mode(self, mode: SelectionMode) -> DataGrid
Sets how rows can be selected (single by default).
Sourcepub fn selection(self, selection: Binding<BTreeSet<usize>>) -> DataGrid
pub fn selection(self, selection: Binding<BTreeSet<usize>>) -> DataGrid
Where the selected row indices live (otherwise the grid keeps them).
Sourcepub fn key_column(self, column: usize) -> DataGrid
pub fn key_column(self, column: usize) -> DataGrid
The column that identifies a record, for selected_keys
and the names of GridRowActions.
Sourcepub fn selected_keys(self, keys: Binding<BTreeSet<String>>) -> DataGrid
pub fn selected_keys(self, keys: Binding<BTreeSet<String>>) -> DataGrid
Where the keys of the selected rows live, with
key_column. Unlike row indices, keys still mean the same
records after the data is replaced.
Sourcepub fn on_row_open(self, handler: impl Fn(&Vec<Value>) + 'static) -> DataGrid
pub fn on_row_open(self, handler: impl Fn(&Vec<Value>) + 'static) -> DataGrid
Double-click or Enter on a row, with the row’s values. Works the same over rows at hand and rows on a server.
Sourcepub fn on_cell_edit(
self,
handler: impl Fn(&CellEdit) -> Result<(), String> + 'static,
) -> DataGrid
pub fn on_cell_edit( self, handler: impl Fn(&CellEdit) -> Result<(), String> + 'static, ) -> DataGrid
Sees each edit before it is kept. An error stays on show, in the toolbar, and the
cell stays open. With it, columns marked editable can
be edited with a double-click over rows on a server too: the handler saves them.
Sourcepub fn row_action(self, action: GridRowAction) -> DataGrid
pub fn row_action(self, action: GridRowAction) -> DataGrid
Adds a button at the end of every row.
Sourcepub fn on_add_row(self, handler: impl Fn() + 'static) -> DataGrid
pub fn on_add_row(self, handler: impl Fn() + 'static) -> DataGrid
Shows an Add button in the toolbar. The handler adds the row, or opens a form to.
Sourcepub fn on_delete_rows(self, handler: impl Fn(Vec<usize>) + 'static) -> DataGrid
pub fn on_delete_rows(self, handler: impl Fn(Vec<usize>) + 'static) -> DataGrid
Lets the Delete key and a toolbar button remove the selected rows. The handler receives them, and it decides: it may ask first.
Sourcepub fn sort_by(self, column: usize, direction: SortDirection) -> DataGrid
pub fn sort_by(self, column: usize, direction: SortDirection) -> DataGrid
Initial sort; call again to add more sort columns.
Sourcepub fn group_by(self, column: usize) -> DataGrid
pub fn group_by(self, column: usize) -> DataGrid
Initial grouping; call again for nested groups.
Sourcepub fn filter_row(self, show: bool) -> DataGrid
pub fn filter_row(self, show: bool) -> DataGrid
Shows or hides the filter row under the header.
Sourcepub fn search_panel(self, show: bool) -> DataGrid
pub fn search_panel(self, show: bool) -> DataGrid
Shows or hides the search box in the toolbar.
Sourcepub fn toolbar(self, show: bool) -> DataGrid
pub fn toolbar(self, show: bool) -> DataGrid
The toolbar with search, grouping, column chooser and export.
The footer with column totals.
Sourcepub fn height(self, height: f32) -> DataGrid
pub fn height(self, height: f32) -> DataGrid
A fixed height; otherwise the grid fills the space its parent gives it.
Sourcepub fn row_height(self, height: f32) -> DataGrid
pub fn row_height(self, height: f32) -> DataGrid
Sets the row height in logical pixels (36 by default, at least 24).
Sourcepub fn striped(self, striped: bool) -> DataGrid
pub fn striped(self, striped: bool) -> DataGrid
Shades every other row with a tint of the theme’s control color, which leaves the accent to the selection. Counting starts again after each group row.
Sourcepub fn even_row(self, color: Color) -> DataGrid
pub fn even_row(self, color: Color) -> DataGrid
Paints the second, fourth and so on rows in this color, in place of Self::striped.
Sourcepub fn odd_row(self, color: Color) -> DataGrid
pub fn odd_row(self, color: Color) -> DataGrid
Paints the first, third and so on rows in this color.
Sourcepub fn horizontal_lines(self, show: bool) -> DataGrid
pub fn horizontal_lines(self, show: bool) -> DataGrid
Whether a line separates the rows. On by default.
Sourcepub fn on_export(self, handler: impl Fn(String) + 'static) -> DataGrid
pub fn on_export(self, handler: impl Fn(String) + 'static) -> DataGrid
Shows an Export button; handler receives the matching rows as CSV.
Sourcepub fn on_row_activate(self, handler: impl Fn(usize) + 'static) -> DataGrid
pub fn on_row_activate(self, handler: impl Fn(usize) + 'static) -> DataGrid
Double-click or Enter on a row whose cell is not editable.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for DataGrid
impl !Send for DataGrid
impl !Sync for DataGrid
impl !UnwindSafe for DataGrid
impl Freeze for DataGrid
impl Unpin for DataGrid
impl UnsafeUnpin for DataGrid
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
Source§impl<V> ViewExt for Vwhere
V: View,
impl<V> ViewExt for Vwhere
V: View,
Source§fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
Source§fn background(self, fill: impl Into<Fill>) -> Styled<Self>
fn background(self, fill: impl Into<Fill>) -> Styled<Self>
Source§fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
None keeps the content size.