Project

General

Profile

Actions

Improvements #13574

open

checkbox in WTableView header is not exactly in the center

Added by Korneel Dumon 10 months ago. Updated 11 days ago.

Status:
Review
Priority:
Normal
Assignee:
-
Target version:
Start date:
02/25/2025
Due date:
% Done:

0%

Estimated time:

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

clipboard-202502251454-zptin.png (12.5 KB) clipboard-202502251454-zptin.png Korneel Dumon, 02/25/2025 02:54 PM
Actions #1

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;

Actions #2

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.

Actions #3

Updated by Romain Mardulyn 12 days ago

  • Status changed from New to InProgress
  • Assignee set to Romain Mardulyn
Actions #4

Updated by Romain Mardulyn 11 days ago

  • Status changed from InProgress to Review
  • Assignee deleted (Romain Mardulyn)
Actions

Also available in: Atom PDF