pub struct DataGrid { /* private fields */ }Expand description
A grid that renders only the rows its viewport holds.
Implementations§
Source§impl DataGrid
impl DataGrid
Sourcepub fn new(
ident: impl Into<Ident>,
count: usize,
render_row: impl Fn(usize, &mut Window, &mut App) -> GridRow + 'static,
) -> Self
pub fn new( ident: impl Into<Ident>, count: usize, render_row: impl Fn(usize, &mut Window, &mut App) -> GridRow + 'static, ) -> Self
count is how many rows the caller has; render_row builds one of
them, and is only ever called for a row that is about to be drawn or
about to be reported.
Sourcepub fn total(self, total: usize) -> Self
pub fn total(self, total: usize) -> Self
How many rows exist on the host, when the grid has been given only some of them. Without it the grid assumes it has everything.
pub fn column(self, column: GridColumn) -> Self
pub fn columns(self, columns: impl IntoIterator<Item = GridColumn>) -> Self
Sourcepub fn lines(self, lines: GridLines) -> Self
pub fn lines(self, lines: GridLines) -> Self
Draws rules between rows, for a grid dense enough to need them.
Sourcepub fn sort(self, sort: Option<(SharedString, SortDirection)>) -> Self
pub fn sort(self, sort: Option<(SharedString, SortDirection)>) -> Self
The sort the caller applied, which is the only sort the grid shows.
pub fn sorted_by( self, key: impl Into<SharedString>, direction: SortDirection, ) -> Self
pub fn selection_mode(self, mode: SelectionMode) -> Self
Sourcepub fn selected(
self,
ids: impl IntoIterator<Item = impl Into<SharedString>>,
) -> Self
pub fn selected( self, ids: impl IntoIterator<Item = impl Into<SharedString>>, ) -> Self
The rows the caller says are selected. The grid renders these and nothing else, whatever a click reported a moment ago.
Sourcepub fn expanded(self, rows: impl IntoIterator<Item = Expanded>) -> Self
pub fn expanded(self, rows: impl IntoIterator<Item = Expanded>) -> Self
The rows the caller has opened, and where each one sits.
Sourcepub fn detail_rows(self, rows: usize) -> Self
pub fn detail_rows(self, rows: usize) -> Self
How many row heights an opened detail region occupies.
Sourcepub fn detail(
self,
render: impl Fn(SharedString, &mut Window, &mut App) -> AnyElement + 'static,
) -> Self
pub fn detail( self, render: impl Fn(SharedString, &mut Window, &mut App) -> AnyElement + 'static, ) -> Self
Builds the detail region for an opened row. Called only for rows the caller has opened and the viewport is drawing.
Sourcepub fn editing(self, cell: Option<EditingCell>) -> Self
pub fn editing(self, cell: Option<EditingCell>) -> Self
The cell the caller has opened for editing, and the value it holds.
pub fn row_height(self, height: f32) -> Self
Sourcepub fn visible_rows(self, rows: usize) -> Self
pub fn visible_rows(self, rows: usize) -> Self
Bounds the viewport to rows rows, which is what lets the grid skip
the rows it does not show.
Sourcepub fn loading(self, loading: bool) -> Self
pub fn loading(self, loading: bool) -> Self
A first load with nothing to show yet. A refresh over rows that already
exist is not this; see DataGrid::failure.
Sourcepub fn failure(self, failure: impl Into<SharedString>) -> Self
pub fn failure(self, failure: impl Into<SharedString>) -> Self
A refresh that failed. Rows the grid already has stay on screen with the failure stated above them; only a failure with nothing behind it takes the surface over.
Sourcepub fn empty(self, empty: EmptyState) -> Self
pub fn empty(self, empty: EmptyState) -> Self
What to show when the query succeeded and returned nothing.
pub fn on_sort( self, handler: impl Fn(SharedString, SortDirection, &mut Window, &mut App) + 'static, ) -> Self
pub fn on_select( self, handler: impl Fn(&SelectionChange, &mut Window, &mut App) + 'static, ) -> Self
Sourcepub fn on_resize(
self,
handler: impl Fn(SharedString, f32, &mut Window, &mut App) + 'static,
) -> Self
pub fn on_resize( self, handler: impl Fn(SharedString, f32, &mut Window, &mut App) + 'static, ) -> Self
Reports the width a drag on a column edge asked for.
Sourcepub fn on_fit(
self,
handler: impl Fn(SharedString, &mut Window, &mut App) + 'static,
) -> Self
pub fn on_fit( self, handler: impl Fn(SharedString, &mut Window, &mut App) + 'static, ) -> Self
Reports that a double click on a column edge asked for a width that fits the content. The grid measures nothing; see the module docs.
Sourcepub fn on_reorder(
self,
handler: impl Fn(&DropIntent, &mut Window, &mut App) + 'static,
) -> Self
pub fn on_reorder( self, handler: impl Fn(&DropIntent, &mut Window, &mut App) + 'static, ) -> Self
Reports where a dragged column should go. The grid does not move it.
Sourcepub fn on_expand(
self,
handler: impl Fn(SharedString, bool, &mut Window, &mut App) + 'static,
) -> Self
pub fn on_expand( self, handler: impl Fn(SharedString, bool, &mut Window, &mut App) + 'static, ) -> Self
Reports the disclosure state a row should take.
Sourcepub fn on_edit_request(
self,
handler: impl Fn(SharedString, SharedString, &mut Window, &mut App) + 'static,
) -> Self
pub fn on_edit_request( self, handler: impl Fn(SharedString, SharedString, &mut Window, &mut App) + 'static, ) -> Self
Reports that a cell was asked to become a field.
Trait Implementations§
Source§impl IntoElement for DataGrid
impl IntoElement for DataGrid
Source§type Element = ViewElement<DataGrid>
type Element = ViewElement<DataGrid>
Source§fn into_element(self) -> Self::Element
fn into_element(self) -> Self::Element
Element.Source§fn into_any_element(self) -> AnyElement
fn into_any_element(self) -> AnyElement
AnyElement.Source§impl RenderOnce for DataGrid
impl RenderOnce for DataGrid
Source§fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
Render::render() method
which takes a mutable reference.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§
Source§impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
Source§fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: 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
Source§impl<E> Flipping for Ewhere
E: IntoElement,
impl<E> Flipping for Ewhere
E: IntoElement,
Source§impl<T> FluentBuilder for Twhere
T: IntoElement,
impl<T> FluentBuilder for Twhere
T: IntoElement,
Source§fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more