pub trait TableDataProvider<Row>{
type ColumnName: Copy;
// Required method
fn get_rows<'life0, 'async_trait>(
&'life0 self,
range: Range<usize>
) -> Pin<Box<dyn Future<Output = Vec<Row>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn set_sorting(
&mut self,
sorting: &VecDeque<(Self::ColumnName, ColumnSort)>
) { ... }
}
Expand description
The trait that provides data for the generated table component.
Anything that is passed to the items
prop must implement this trait.
This is automatically implemented for Vec<Row>
.
This way a simple list of items can be passed to the table.
Please note that because of the use of async-trait
this documentation is a bit cluttered.
Required Associated Types§
sourcetype ColumnName: Copy
type ColumnName: Copy
This is generated by deriving TableComponent. It’s an enum with all the column names.
Required Methods§
sourcefn get_rows<'life0, 'async_trait>(
&'life0 self,
range: Range<usize>
) -> Pin<Box<dyn Future<Output = Vec<Row>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_rows<'life0, 'async_trait>(
&'life0 self,
range: Range<usize>
) -> Pin<Box<dyn Future<Output = Vec<Row>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get all data rows for the table specified by the range. This method is called when the table is rendered.
The range is determined by the visible rows and used to virtualize the table.
The parameter range
is only determined by visibility and may be out of bounds. It is the
responsibility of the implementation to handle this case. Use get_vec_range_clamped to get a
range that is clamped to the length of the vector.
Provided Methods§
sourcefn set_sorting(&mut self, sorting: &VecDeque<(Self::ColumnName, ColumnSort)>)
fn set_sorting(&mut self, sorting: &VecDeque<(Self::ColumnName, ColumnSort)>)
Set the sorting of the table. The sorting is a list of column names and the sort order sorted by priority.
The first entry in the list is the most important one.
The default implementation does nothing.
For example: [(Column::Name, ColumnSort::Ascending), (Column::Age, ColumnSort::Descending)]
will sort by name first and then by age.
Please note that after calling this method, data will be reloaded through get_rows
.