Bug #2111
closedLast column header text of a WTableView is not rendered
0%
Description
Hi,
I have written a ItemViewAutoSize adapter class which resizes the columns of the WTableView according to its contents. I use the setLayoutAware(true) feature to be notified when the table view changes it size.
The ItemTableView::calcColumns() methods needs to be called after the model is completed populated.
Attached you will find 2 classes which implements the feature and a screenshot which shows the bug. The last column header (HTTP, XXX) displays no test this should be "Group" in this example.
Regards,
Stefan
Files
Updated by Koen Deforche over 11 years ago
- Status changed from New to Feedback
- Assignee set to Koen Deforche
- Target version set to 3.3.1
Hey Stefan,
What version of Wt are you using and is this a regression?
Does your auto-size-adjusting feature interfere with this, i.e. is the last column header text rendered correctly without your size adjustments?
Will I be able to reproduce the problem with just any model, and how should I implement the tableview to connect to your function?
Regards,
koen
Updated by Stefan Ruppert over 11 years ago
Hi Koen,
this is not a regression. I noticed this problem since I implemented this feature (in the time I used Wt 3.2.3 I think). But my first implementation was integrated in a complex table view, therefore I could not easily extract a test case from it. A workaround for me was to add an empty column at the end which used only 7 pixel of space... ;-)
Now I needed a general way of a auto-size feature and implemented the ItemTableView and ItemViewAutoSize classes.
I currently use kdeforche-wt-3.3.0-33-g2d4882f git version. And yes if I disable the autoSize feature by setting WTableView::setLayoutSizeAware(false) the last column header test is correctly shown!
Also sometimes the last column header texts shows up. Maybe a "if((width % fontWidth) == 0)" problem???
I think the problem shows up with any model.
You can just subclass the ItemTableView class and add this table view to a layout. Once the attached model has loaded all data you have to call ItemTableView::calcColumns(). I don't use a model signal since calcColumns() will iterate over all columns and rows for calculating the best auto layout. Thus I will only call this method if I know the model does not change anymore!
Here is one of my implementation:
class RTSConfigTableView : public ItemTableView
{
public:
RTSConfigTableView(Wt::WAbstractItemModel* model)
: ItemTableView(model)
{
const size_t columns = model->columnCount();
const AlignmentFlag columnAlign[] = {AlignLeft, AlignLeft, AlignLeft, AlignRight, AlignRight, AlignRight, AlignRight, AlignLeft};
for(size_t c=0; c<columns; ++c)
setColumnAlignment(c, columnAlign[c]);
setAlternatingRowColors(true);
setColumnBorder(WColor(200,200,200));
}
};
Updated by Koen Deforche about 11 years ago
- Status changed from Feedback to Resolved
Hey,
I could reproduce it now, thanks. It's indeed because of the rounding. It is not well specified what a browser should do with a non-integral (pixel-based) width or height; in particular how that affects the positioning of sibling cells.
I've added a fix in WTableView which will round the given width, which fixes the problem that the header text drops from the table, but I guess you should set integral widths to begin width since otherwise you might get a scrollbar depending on rounding effects.
Regards,
koen
Updated by Stefan Ruppert about 11 years ago
Hi Koen,
that sounds great.
But I don't know if I mentioned that this bug also occured within WTreeView? Could you apply your fix also to the WTreeView class?
Regards,
Stefan
Updated by Koen Deforche about 11 years ago
Hey Stefan,
I'll also consider WTreeView.
Regards,
koen
Updated by Koen Deforche about 11 years ago
- Status changed from Resolved to Closed