pub trait DataTableSource: ListenableObject {
// Required methods
fn get_row(
self: Handle<Self>,
app: &mut App,
index: usize,
) -> Option<DataRow>;
fn row_count(self: Handle<Self>, app: &App) -> usize;
fn is_row_count_approximate(self: Handle<Self>, app: &App) -> bool;
fn selected_row_count(self: Handle<Self>, app: &App) -> usize;
// Provided method
fn as_data_table_source(self: Handle<Self>) -> AnyDataTableSource { ... }
}Expand description
A data source for obtaining row data for PaginatedDataTable
objects.
A data table source provides two main pieces of information:
- The number of rows in the data table (
row_count). - The data for each row (indexed from
0torow_count - 1).
It also provides some control over sort indicators and which rows are selected.
The data source is expected to expose some mechanism for sorting the data. To retrieve a
row’s data, get_row is called with the row’s index. The data source
notifies its listeners whenever the data changes. It is the data source’s responsibility to
be a ChangeNotifier, which gives it its ListenableObject side.
Dart’s abstract DataTableSource extends ChangeNotifier: a data source is an arena object
that holds ChangeNotifierData and implements ChangeNotifier.
Required Methods§
Sourcefn get_row(self: Handle<Self>, app: &mut App, index: usize) -> Option<DataRow>
fn get_row(self: Handle<Self>, app: &mut App, index: usize) -> Option<DataRow>
Called to obtain the data about a particular row.
Rows should be keyed so that state can be maintained when the data source is sorted
(e.g. with DataRow::by_index).
Return None if the data for this row is unavailable (for example, if the row is
still being loaded). The table will show a progress indicator for the first unavailable
row of each page.
If the given index is greater than or equal to row_count, this
method should return None (but if is_row_count_approximate
is true, it may instead return a row for the data not yet loaded).
Sourcefn row_count(self: Handle<Self>, app: &App) -> usize
fn row_count(self: Handle<Self>, app: &App) -> usize
Called to obtain the number of rows to tell the user are available.
If is_row_count_approximate is false, then this
must be an accurate number, and get_row must return a non-null value
for all indices in the range 0 to one less than the row count.
If is_row_count_approximate is true, then this must
be an estimate.
Sourcefn is_row_count_approximate(self: Handle<Self>, app: &App) -> bool
fn is_row_count_approximate(self: Handle<Self>, app: &App) -> bool
Called to establish if row_count is a precise number or might be
an over-estimate. If this returns true (i.e. the count is approximate), and then later
the exact number becomes available, then call notify_listeners.
Sourcefn selected_row_count(self: Handle<Self>, app: &App) -> usize
fn selected_row_count(self: Handle<Self>, app: &App) -> usize
Called to obtain the number of rows that are currently selected.
If the selected row count changes, call notify_listeners.
Selected rows are those whose DataRow::selected property is set to true.
Provided Methods§
Sourcefn as_data_table_source(self: Handle<Self>) -> AnyDataTableSource
fn as_data_table_source(self: Handle<Self>) -> AnyDataTableSource
The type-erased DataTableSource handle. Free: the vtable is a const, and the id is
copied.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".