table: Add refresh method to Table, for reload table use when the columns or rows has been updated. (#293)

This commit is contained in:
ihavecoke 2024-10-02 17:29:50 +08:00 committed by GitHub
parent 7de1c6981e
commit b9e7217662
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 7 deletions

View file

@ -283,13 +283,8 @@ impl TableDelegate for StockTableDelegate {
}
fn col_width(&self, col_ix: usize) -> Option<Pixels> {
if let Some(col) = self.columns.get(col_ix) {
Some(
match col.id.as_ref() {
_ => 120.0,
}
.into(),
)
if let Some(_) = self.columns.get(col_ix) {
Some(120.0.into())
} else {
None
}

View file

@ -288,6 +288,11 @@ where
cx.notify();
}
/// When we update columns or rows, we need to refresh the table.
pub fn refresh(&mut self, cx: &mut ViewContext<Self>) {
self.prepare_col_groups(cx);
}
fn prepare_col_groups(&mut self, cx: &mut ViewContext<Self>) {
self.col_groups = (0..self.delegate.cols_count())
.map(|col_ix| ColGroup {