Project

General

Profile

WTableView refresh problem + model updates

Added by Paolo Greppi over 11 years ago

In the attached example, the Wt::WComboBox::activated events change the number of columns or the heading/data in a Wt::WAbstractTableModel-derived class (VirtualTable) which is set as the model of a Wt::WTableView.

There is one issue when this is run with Wt 3.1.10 / boost 1.49.0 and in Chromium 23:

  • the page is initially loaded fine (00before.png)
  • if I change the number of columns from the respective defaults to the maximum (49) I get what you see in the 01after.png screenshot; the cells that should have been added are not there (although the horizontal scroll bars hint at them); in some cases you see a light grey triangle where a cell should have been
  • if I scrool to the right, enough to "turn page", suddenly the cells are there (02scrolled.png)

Also I have three questions:

  • how to have the WTableView react to the changes in the model resulting from changing the heading and the data ?
  • I manually set the table height to a value that accomodates the table with or without the horizontal scrollbar; how can I adadpt the height automatically so that no space is wasted when no scrollbar is present ?
  • what is the maximum number of columns that reasonably the WTableView will be able to show ?

TIA


Replies (5)

RE: WTableView refresh problem + model updates - Added by Koen Deforche over 11 years ago

Hey Paolo,

The problem that you see has been fixed in more recent versions.

As to your questions:

  • a table view will automatically reflect changes from a model, at least if the model properly emits the signals (see WAbstractItemModel).
  • In more recent versions, a table view will do that automatically.
  • the only limit is that there are (undocumented) maximum values to CSS lengths. We should probably track this for different browsers in order to know.

Regards,

Koen

Regards,

Koen

RE: WTableView refresh problem + model updates - Added by Paolo Greppi over 11 years ago

Are you sure the problem has been fixed in recent versions ?

I have tried the code I attached last week against wt 3.2.1 (rather 3.1.10) on debian7 amd64 and get the same behavior as in the 01after.png screenshot; plus, the header is now invisible, it turns out because it has set margin-top: --9.66368e+10px on the

containing the

Heading

as you can see with firebug in the attached 01after_3.2.1_amd64.png screenshot.

Also the table does not resize the height automatically: if I remove the line table_resize(Wt::WLength::Auto, 20 + 45 + 22); or replace it with table_>resize(Wt::WLength::Auto, Wt::WLength::Auto) I get all garbled as in 03_no_resize.png.

As to the limits, would it bear 40000 (fourty thousand) columns ?

Finally, I have more questions:

  • if the table cells are editable how to pick up the new value as soon as the user takes away the focus from the cell by not pressing enter and rather clicking somehere else ? it looks like it is just listening to the enterPressed() and not the changed() event of a Wt::WLineEdit; this problem is also present in the charts.wt example: if I enter edit mode for a cell then enter a new value and press enter OK, if I enter edit mode for a cell then enter a new value and take away the focus by entering edit mode in another cell OK, but if I enter edit mode for a cell then enter a new value and take away the focus by clicking on the white background of the page, the editor stays open and the value is not picked up
  • how to be able to move from once cell editor to the other by using TAB, SHIFT+TAB and the arrows ?
  • how to be able to paste a mass of TAB-separated values from the clipboard to populate a table ?

RE: WTableView refresh problem + model updates - Added by Koen Deforche over 11 years ago

Hey,

Layout managers were redone since, and thus I would recommend trying with 3.2.3.

40000 columns is probably not feasible because of the pixel width limitation... how would a user be supposed to navigate so much data?

You could also consider grouping colums, with supports this which works like a tree structure but then for columns.

Regards,

Koen

RE: WTableView refresh problem + model updates - Added by Koen Deforche over 11 years ago

Hey,

As to editing :

- save when leave behaviour : yes this can be configured using setEditOptions.

- navigation with arrows will work only if you open multiple editors, but this becomes slow quickly since the default item delegate uses a layout manager for every cell that has its editor open.

  • I have recently implemented this for a customer project, it is feasible but requires customized delegates which use a text area instead of a line edit

Regards,

Koen

RE: WTableView refresh problem + model updates - Added by Paolo Greppi over 11 years ago

With 3.2.3:

  • the issue with the missing cells is solved
  • the table view hides/reveals the horizontal scrollbar as required and it adadpts the height automatically so that no space is wasted when no scrollbar is present, when I use resize(Wt::WLength::Auto, Wt::WLength::Auto).

I fixed the model to properly emit the required signals and now the view reacts OK to the changes in the model. I attach the modified code in case it is useful as an example.

For pasting TAB-separated values from the clipboard to populate a table, I'll probably do it with a custom button that manipulates the model directly.

So far these issues are left open:

  • save when leave behaviour: I have tried with this code: Wt::WFlagsWt::WAbstractItemView::EditOption flags = Wt::WAbstractItemView::SingleEditor; flags |= Wt::WAbstractItemView::SaveWhenClosed; table_->setEditOptions(flags);

in this way, the value is picked up when the editor is closed; the problem is that it does not suffice to take away the focus from the cell by clicking somehere else out of the table to close the editor - only clicking in another cell or pressing enter work. This could be improved ! Failing to press enter is the single most frequent mistake that confuses the users

  • re. moving between cells with TAB, SHIFT+TAB and the arrows: can we catch keyboard events, close the current delegate and open the next one as required ?

Thanks

Paolo

    (1-5/5)