Improvements #13574
opencheckbox in WTableView header is not exactly in the center
0%
Description
When the first column consists entirely of checkboxes then the header is not aligned with the rest of the column:

I tested it in the widgetgallery by modifying SmallTableView.cpp like this:
...
auto model = csvToModel(WApplication::appRoot() + "table.csv");
model->setHeaderFlags(0, Wt::Orientation::Horizontal, Wt::HeaderFlag::UserCheckable);
model->setHeaderData(0, Wt::Orientation::Horizontal, {});
model->setHeaderData(0, Wt::Orientation::Horizontal, Wt::CheckState::Checked, Wt::ItemDataRole::Checked);
for (std::size_t i=0; i < model->rowCount(); ++i) {
auto item = model->item(i, 0);
item->setText("");
item->setCheckable(true);
}
tableView->setModel(model);
...
Files
Updated by Michael Seibt 25 days ago
This is a fundamental issue. It can be seen with simple text cells, too.
The header cells have both a margin-left and a padding-left of 6px from table-view.scss:5 (".Wt-tableview .Wt-header .Wt-tv-c").
That's why AlignmentFlag::Left and AlignmentFlag::Center cannot work properly.
And it increases the column width unnecessarily.
What is the purpose of this spacing at the left of header cells?
Overriding this CSS does not help because this extra-spacing is taken into account by means of hard-coded magic numbers in WTableView.C.
The width of header cells is 6px less than the width of contents cells (both set a element level).
The alignment would be correct with:
padding-left: 0px;
margin-left: 3px;
Updated by Matthias Van Ceulebroeck 20 days ago
- Target version set to 4.13.2
I believe this is a "solution" to the perceived offset introduced by making columns sort-able. The icons to indicate the column can be sorted are a couple pixels wide, and this offset causes any actually centered content to be perceived as not being centered.
Updated by Romain Mardulyn 12 days ago
- Status changed from New to InProgress
- Assignee set to Romain Mardulyn
Updated by Romain Mardulyn 11 days ago
- Status changed from InProgress to Review
- Assignee deleted (
Romain Mardulyn)