pub struct TableViewSource<T> { /* private fields */ }Expand description
XAML TableViewSource: the items a TableView shows and the shape it shows them in.
The application makes one with TableViewSource::from, hands it to one TableView, and disposes it after the view.
Implementations§
Source§impl<T: 'static> TableViewSource<T>
impl<T: 'static> TableViewSource<T>
Sourcepub fn from(app: &mut App, items: Vec<T>) -> Ref<Self>
pub fn from(app: &mut App, items: Vec<T>) -> Ref<Self>
TableViewSource.From: a source over items, unshaped, its view populated by the time it returns.
Sourcepub fn dispose(self: Handle<Self>, app: &mut App)
pub fn dispose(self: Handle<Self>, app: &mut App)
Releases the listeners; the source is not used after.
Sourcepub fn item_count(self: Handle<Self>, app: &App) -> usize
pub fn item_count(self: Handle<Self>, app: &App) -> usize
How many items there are.
Sourcepub fn item(self: Handle<Self>, app: &App, index: usize) -> &T
pub fn item(self: Handle<Self>, app: &App, index: usize) -> &T
The item at index, in source order.
Sourcepub fn set_items(self: Handle<Self>, app: &mut App, items: Vec<T>)
pub fn set_items(self: Handle<Self>, app: &mut App, items: Vec<T>)
Replaces the items, as the collection the source wraps raising a reset: the filter and the sorts stay, the view is rebuilt from the new items, and a TableView showing the source clears its selection (SelectionNode::OnSourceListChanged, Reset).
Sourcepub fn insert(self: Handle<Self>, app: &mut App, index: usize, item: T)
pub fn insert(self: Handle<Self>, app: &mut App, index: usize, item: T)
Inserts item at index of the items, as the collection raising Add: its row goes to its place in the view, unless the filter leaves it out.
Sourcepub fn remove(self: Handle<Self>, app: &mut App, index: usize)
pub fn remove(self: Handle<Self>, app: &mut App, index: usize)
Removes the item at index, as the collection raising Remove: its row, if shown, is removed.
Sourcepub fn replace(self: Handle<Self>, app: &mut App, index: usize, item: T)
pub fn replace(self: Handle<Self>, app: &mut App, index: usize, item: T)
Replaces the item at index with item, as the collection raising Replace: without a sort its row shows the new item; with one the row is removed and the new item inserted at its place. A row replaced is no longer selected, as SelectionNode treats a replacement as a removal and an insertion; update keeps it.
Sourcepub fn update(
self: Handle<Self>,
app: &mut App,
index: usize,
change: impl FnOnce(&mut T),
)
pub fn update( self: Handle<Self>, app: &mut App, index: usize, change: impl FnOnce(&mut T), )
Changes the item at index in place, as an item raising PropertyChanged: its row shows the new values and stays selected, and moves to its new place if a sort key changed, or leaves or joins the view if the filter’s answer did.
Sourcepub fn view(self: Handle<Self>, app: &App) -> &[usize]
pub fn view(self: Handle<Self>, app: &App) -> &[usize]
View: each row of the projection, as its index in the items.
Sourcepub fn filter(
self: Handle<Self>,
app: &mut App,
predicate: impl Fn(&T) -> bool + 'static,
) -> Handle<Self>
pub fn filter( self: Handle<Self>, app: &mut App, predicate: impl Fn(&T) -> bool + 'static, ) -> Handle<Self>
Filter: the only items shown are those predicate keeps, in source order before any sort. Each call replaces the previous predicate.
Sourcepub fn clear_filter(self: Handle<Self>, app: &mut App) -> Handle<Self>
pub fn clear_filter(self: Handle<Self>, app: &mut App) -> Handle<Self>
ClearFilter: nothing at all when no filter is set, not even a rebuild.
Sourcepub fn sort<K: Ord>(
self: Handle<Self>,
app: &mut App,
key: impl Fn(&T) -> K + 'static,
direction: SortDirection,
) -> Handle<Self>
pub fn sort<K: Ord>( self: Handle<Self>, app: &mut App, key: impl Fn(&T) -> K + 'static, direction: SortDirection, ) -> Handle<Self>
Sort: adds a sort axis ordering the rows by key in direction, after the axes already declared, which it breaks ties within. SortDirection::None adds nothing.
Sourcepub fn clear_sort(self: Handle<Self>, app: &mut App) -> Handle<Self>
pub fn clear_sort(self: Handle<Self>, app: &mut App) -> Handle<Self>
ClearSort: every axis, the ones a TableView installed included; nothing when there are none.
Trait Implementations§
Source§impl<T: 'static> ChangeNotifier for TableViewSource<T>
impl<T: 'static> ChangeNotifier for TableViewSource<T>
fn change_notifier_data(&self) -> &ChangeNotifierData
fn change_notifier_data_mut(&mut self) -> &mut ChangeNotifierData
Source§fn will_add_listener(self: Handle<Self>, app: &mut App)
fn will_add_listener(self: Handle<Self>, app: &mut App)
addListener that
work before super.addListener go here.Source§fn did_remove_listener(self: Handle<Self>, app: &mut App)
fn did_remove_listener(self: Handle<Self>, app: &mut App)
removeListener that
work after super.removeListener go here.