0 votes
644 views
in Coach Views by (190 points)
how to autofit table by content?

1 Answer

0 votes
ago by (30.6k points)

The UI Toolkit Table uses a Bootstrap table with fixed column widths taken from the column definitions; to size columns by their content, remove the fixed widths and let the browser lay out the table:

/* managed CSS asset included by the coach view or the page */
.myTable table { table-layout: auto !important; width: auto !important; }
.myTable th, .myTable td { white-space: nowrap; }
  • Leave the width of every column empty in the column settings and give the table the CSS class myTable (the Custom CSS class option). Columns then take the width of their widest content; add max-width on long text columns to avoid a horizontal scroll bar.
  • To size on load from JavaScript (for example after a service fills the list), the table's On rendered event is the place to measure and set widths: iterate table.querySelectorAll("th") and set style.width from scrollWidth.
  • Row height follows the content automatically; if rows look clipped, the culprit is a control inside the cell with a fixed height (Text with rows=1) - set height = auto on it.
  • Responsive tables: the toolkit's Responsive option turns rows into stacked cards on small screens, which is the better fit than autofit on phones.

References

Related questions

0 votes
1 answer 4.1k views
0 votes
1 answer 1.6k views
0 votes
1 answer 1.7k views
0 votes
1 answer 1.4k views
+1 vote
1 answer 1.2k views
0 votes
1 answer 1.1k views
0 votes
1 answer 867 views
0 votes
1 answer 1.2k views
asked Feb 13, 2021 by Manana (190 points)
0 votes
1 answer 3.3k views
0 votes
1 answer 2.3k views
0 votes
1 answer 845 views
0 votes
1 answer 2.4k views
asked Oct 17, 2023 in Coach Views by raik (120 points)
0 votes
1 answer 2.7k views

723 questions

807 answers

98 comments

4.9k users

Join BPM Community Discord Channel

Welcome to BPM Tips Q&A, Community wiki/forum where you can ask questions and receive answers from other IBM BPM experts and members of the community. Users with 2000 points will automatically be promoted to expert level.
Created by Dosvak LLC
Our Youtube Channel
...