table: Add refresh method to Table, for reload table use when the columns or rows has been updated. (#293)
This commit is contained in:
parent
7de1c6981e
commit
b9e7217662
2 changed files with 7 additions and 7 deletions
|
|
@ -283,13 +283,8 @@ impl TableDelegate for StockTableDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn col_width(&self, col_ix: usize) -> Option<Pixels> {
|
fn col_width(&self, col_ix: usize) -> Option<Pixels> {
|
||||||
if let Some(col) = self.columns.get(col_ix) {
|
if let Some(_) = self.columns.get(col_ix) {
|
||||||
Some(
|
Some(120.0.into())
|
||||||
match col.id.as_ref() {
|
|
||||||
_ => 120.0,
|
|
||||||
}
|
|
||||||
.into(),
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -288,6 +288,11 @@ where
|
||||||
cx.notify();
|
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>) {
|
fn prepare_col_groups(&mut self, cx: &mut ViewContext<Self>) {
|
||||||
self.col_groups = (0..self.delegate.cols_count())
|
self.col_groups = (0..self.delegate.cols_count())
|
||||||
.map(|col_ix| ColGroup {
|
.map(|col_ix| ColGroup {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue