WTableView Refresh

Added by Mark Petryk 11 months ago

I'd like to call something on a WTableView that causes a 'refresh' of the data.

  auto tableView = std::make_unique<Wt::WTableView>();
  tableView-> setModel( resultModel ); // assign a query with 1000's of rows of data

If my 'resultModel' has 1000's of rows of data, if I change any of the underlying data, and then if I "scroll out of view" the item that I had edited, and then "scroll back in to view" that item, the data in it is refreshed, reflecting the change to the underlying item.

What could I call to get this to happen manually?

I am opening a "detail form" on any item, editing it, and saving it, and I'd like the table underneath to update with those new values.

But I don't want to rebuild the model, or "refresh" the table, as this causes everything to shift around, and I loose my 'selected item' and so on.

Replies (2)

RE: WTableView Refresh - Added by Mark Petryk 9 months ago

Call AbstractItemModel::reset(), but you have to sub-class the model because this method is protected.


RE: WTableView Refresh - Added by Mark Petryk 9 months ago

Then again... calling QueryModel::reload() also accomplishes the same result, but also leaves the selected item still selected.