Skip to main content

DataGrid

Struct DataGrid 

Source
pub struct DataGrid { /* private fields */ }
Expand description

A grid that renders only the rows its viewport holds.

Implementations§

Source§

impl DataGrid

Source

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.

Source

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.

Source

pub fn column(self, column: GridColumn) -> Self

Source

pub fn columns(self, columns: impl IntoIterator<Item = GridColumn>) -> Self

Source

pub fn lines(self, lines: GridLines) -> Self

Draws rules between rows, for a grid dense enough to need them.

Source

pub fn sort(self, sort: Option<(SharedString, SortDirection)>) -> Self

The sort the caller applied, which is the only sort the grid shows.

Source

pub fn sorted_by( self, key: impl Into<SharedString>, direction: SortDirection, ) -> Self

Source

pub fn selection_mode(self, mode: SelectionMode) -> Self

Source

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.

Source

pub fn expanded(self, rows: impl IntoIterator<Item = Expanded>) -> Self

The rows the caller has opened, and where each one sits.

Source

pub fn detail_rows(self, rows: usize) -> Self

How many row heights an opened detail region occupies.

Source

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.

Source

pub fn editing(self, cell: Option<EditingCell>) -> Self

The cell the caller has opened for editing, and the value it holds.

Source

pub fn row_height(self, height: f32) -> Self

Source

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.

Source

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.

Source

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.

Source

pub fn empty(self, empty: EmptyState) -> Self

What to show when the query succeeded and returned nothing.

Source

pub fn on_sort( self, handler: impl Fn(SharedString, SortDirection, &mut Window, &mut App) + 'static, ) -> Self

Source

pub fn on_select( self, handler: impl Fn(&SelectionChange, &mut Window, &mut App) + 'static, ) -> Self

Source

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.

Source

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.

Source

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.

Source

pub fn on_expand( self, handler: impl Fn(SharedString, bool, &mut Window, &mut App) + 'static, ) -> Self

Reports the disclosure state a row should take.

Source

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.

Source

pub fn on_edit( self, handler: impl Fn(&EditIntent, &mut Window, &mut App) + 'static, ) -> Self

Reports how an edit ended, and what was in the field when it did.

Trait Implementations§

Source§

impl Debug for DataGrid

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Disableable for DataGrid

Source§

fn disabled(self, disabled: bool) -> Self

Source§

impl IntoElement for DataGrid

Source§

type Element = ViewElement<DataGrid>

The specific type of element into which the implementing type is converted. Useful for converting other types into elements automatically, like Strings
Source§

fn into_element(self) -> Self::Element

Convert self into a type that implements Element.
Source§

fn into_any_element(self) -> AnyElement

Convert self into a dynamically-typed AnyElement.
Source§

impl RenderOnce for DataGrid

Source§

fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement

Render this component into an element tree. Note that this method takes ownership of self, as compared to Render::render() method which takes a mutable reference.
Source§

impl Sizable for DataGrid

Source§

fn control_size(self, size: ControlSize) -> Self

Source§

fn xs(self) -> Self

Source§

fn small(self) -> Self

Source§

fn medium(self) -> Self

Source§

fn large(self) -> Self

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<E> AnimationExt for E
where 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,

Render this component or element with an animation
Source§

fn with_animations( self, id: impl Into<ElementId>, animations: Vec<Animation>, animator: impl Fn(Self, usize, f32) -> Self + 'static, ) -> AnimationElement<Self>
where Self: Sized,

Render this component or element with a chain of animations
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<E> Flipping for E
where E: IntoElement,

Source§

fn flip(self, flip: &Flip, window: &mut Window, cx: &mut App) -> Flipped

Wraps the element so a change in its position is played back as a slide. Read more
Source§

fn flip_size(self, flip: &Flip, window: &mut Window, cx: &mut App) -> Flipped

The same, and a change in the element’s size is played back too. Read more
Source§

impl<T> FluentBuilder for T
where T: IntoElement,

Source§

fn map<U>(self, f: impl FnOnce(Self) -> U) -> U
where Self: Sized,

Imperatively modify self with the given closure.
Source§

fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
where Self: Sized,

Conditionally modify self with the given closure.
Source§

fn when_else( self, condition: bool, then: impl FnOnce(Self) -> Self, else_fn: impl FnOnce(Self) -> Self, ) -> Self
where Self: Sized,

Conditionally modify self with the given closure.
Source§

fn when_some<T>( self, option: Option<T>, then: impl FnOnce(Self, T) -> Self, ) -> Self
where Self: Sized,

Conditionally unwrap and modify self with the given closure, if the given option is Some.
Source§

fn when_none<T>( self, option: &Option<T>, then: impl FnOnce(Self) -> Self, ) -> Self
where Self: Sized,

Conditionally unwrap and modify self with the given closure, if the given option is None.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> View for T
where T: RenderOnce,

Source§

fn entity_id(&self) -> Option<EntityId>

This view’s identity, if it has one. A view typically holds the backing entity as a field and returns its EntityId here. Read more
Source§

fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement

Render this view into an element tree, consuming self.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more