How to set header and row heights in Tabulator? - tabulator

For a custom React component I wrapped Tabulator and would love to support custom heights for a table header and indvidual rows. I only found row resizing in the documentation, but no information about how to set a custom height in the data (or through an API call).

It's not clear to me from your question if you want to control the height of all rows or just particular ones.
If you want to control height based on data you can use a row formatter. Works well in my experience.
There is also this answer about overriding the CSS for rows: Adjust tabulator row height
.tabulator-row {
position: relative;
box-sizing: border-box;
min-height: 22px;
background-color: #fff;
}

Related

Min Height for GridLayout Row set to Auto

In a GridLayout, I have set a row to 'auto' because the content size is dynamic. In particular, I have a pulldown menu in the row. When it opens, the row correctly grows to the height of the pulldown list that appears. BUT, when the pulldown is closed, it is merely a button that should have the same height as the other rows. Unfortunately, the row height is a bit too small and causes the overall layout to look bad.
To fix this, I need to set the minimum height of the 'auto' row. Is this possible? Can I set a minimum height for a GridLayout row that is set to 'auto' ???
You can not set minimum height for a particular grid row, instead you can set minHeight (min-height with CSS) on the Button you are talking about / simply wrap the Button with a ContentView / StackLayout if you like to keep the Button smaller while giving it more space.

Remove all between two exact expressions in excel

Im trying to do something with my opencart store, i want to remove wrong formatting from all product descriptions, so i made one export in excel of all my products and descriptions ( products are near 8000) and i want to do this io this is my exported description in one cell in excel:
<span style="font-weight: bold; color: rgb(37, 37, 37); font-family: "Myriad Pro", Verdana, Arial, sans-serif; font-size: 13px;">Единичен апликатор, с който лесно се нанасят сенките за очи.</span>
i want to delete everything between
style="font-weight: bold;
and
">
(because i need to use onlu bolded words to stay)
Can i use some formula in excel to do this?
Thanks!
If your text is in cell A1 use the below formula,
=LEFT(A1,FIND("font-weight: bold",A1)+17)&MID(A1,FIND(""">",A1),LEN(A1))
The formula searches for the text font-weight: bold in the cell A1 and strips the left most part till the text. The next part is finding the "> and stripping the character after that. The & is to concatenate both

Adjusting width of column to content in p:dataTable

I want the columns of my table to adjust its width to the biggest element.
Like doubleclicking an excel-column...
I've tried lots of attributes and solutions of other questions but nothing really did what i wanted.
Here are my settings for the dataTable which is nested in a p:scollPanel:
<p:dataTable scrollable="true" scrollWidth="auto" scrollHeight="390"
tableStyle="width: auto; white-space: nowrap; font-size: smaller"
id=carTable" var="vehicles"
value="#{dgBean.vehicles}">
Using:
primefaces 6.0
jsf 2.2.1
UPDATE:
I don't know why, but it seems like table-layout: auto is not used AND two divs are generated. 1 for the Header of my table and the other for the body of my table.
That's why the first layout I've posted shows up and the header and body fit nicely on their own but the header doesn't fit the body.
Generated HTML:
<div class="ui-widget-header ui-datatable-scrollable-header" style="width: 1199px;">
<div class="ui-datatable-scrollable-header-box" style="margin-right: 15px;">
<table role="grid">
<thead id="j_idt5:j_idt14:carTable_head">...</thead>
</table>
</div>
</div>
<div class="ui-datatable-scrollable-body" tabindex="-1" style="height: 390px; margin-right: 0px; width: 1199px;">
<table role="grid">
<thead class="ui-datatable-scrollable-theadclone" style="height: 0px;">...</thead>
<tbody id="j_idt5:j_idt14:carTable_data" class="ui-datatable-data ui-widget-content" tabindex="0">...</tbody>
</table>
</div>
So it seems like 2 tables are generated. Does anyone have a clue how to fix this using pf?
UPDATE from comment
Applying
.ui-datatable-scrollable-header-box table, .ui-datatable-scrollable-footer-box table, .ui-datatable-scrollable-body table {
table-layout: auto;
}
to the Showcase
produces (deleted my former images as reputation is not high enough for more than 2):
Showcase with edited css
I want the columns of my table to adjust its width to the biggest element.
PrimeFaces DataTable default style uses table-layout: fixed;. So if only that, replace your tableStyle content with table-layout: auto; to make usage of the automatic table layout algorithm as stated on w3schools.com:
The column width is set by the widest unbreakable content in the cells
From everthing you wrote (including comments) until now, I assume you want a vertically and horizontally scrollable DataTable that automatically sizes its columns to its content.
I claim this is not possible with the built in functionalities of PrimeFaces DataTable, because as you allready noted, if you make the DataTable scrollable, the rendered output differs in that there are different tables for the header, body and footer (to make header and footer sticky).
I don't get it why its not working.
Column sizes calculated with the automatic table layout algorithm with table-layout: auto; will differ for all three tables (except they incidentally have the same broadest unbreakable content, like header and footer in ShowCase). The difference in size gets relativated if the table gets broader (because additional space is equaly distributed to the columns), so it might look like everthing is OK as Kukeltje commented. But if you shrink the width of the table, differences get visible.
| broadest content | stretched by 1000
--------------------------------------------------------
| column 1 | column 2 | column 1 | column 2
--------------------------------------------------------
header table | 2 | 3 | 502 | 503
body table | 4 | 6 | 504 | 506
footer table | 2 | 3 | 502 | 503
As you maybe have noticed, the rendered body table also contains the header content but hidden. So assumed the header content would be broader than the body content, everything would be fine at least for the header and body table.
| broadest content
========================================
| column 1 | column 2
========================================
header table | 5 | 7
----------------------------------------
hidden header part | 5 | 7
body part | 4 | 6
________________________________________
body table | 5 | 7
----------------------------------------
footer table | 2 | 3
The easiest workaround is to disable scrollability and enable pagination. With this, you have a more or less controllable height of the DataTable (with rows attribute) while preserving the remaining requirements.
From my point of view the paginator looks like it is just replacing the vertical scrolling.
More or less (therefore the easiest workaround). Most important thing is that only one table is renderd and therefore header, body and footer content is used to calculate the column widths:
| broadest content
---------------------------------
| column 1 | column 2
---------------------------------
header part | 2 | 3
body part | 4 | 6
footer part | 2 | 3
_________________________________
full table | 4 | 6
How does that aid my horizontal problem?
With table-layout: auto; you get horizontal scrolling within the paginator viewport out of the box.
Another approach is to disable scrollability and wrap the DataTable with a ScrollPanel. This has some disadvantages in that the header is scrollable too and there are issues with resizing you have to handle, so I would not recommend it.
Best solution will be a customized renderer (note the hidden header content in the rendered body table if scrollability is enabled and extend vice verca) and/or customized JS/CSS for your DataTable, but thats out of scope of your question.
Easiest solution would be to not insist on automatic column sizing according to table content and take DataTable with scrolling capabilities as is.
i had the same issue header and table content width was different, i created below css and worked like a charm for me, don't have to remove anything like filters or scrollbars
.ui-datatable-scrollable-header-box table th, .ui-datatable-scrollable-footer-box table th, .ui-datatable-scrollable-body table td{
width: 20% !important;
}

How to click on a table cell containing known text?

Using Watir, I want to click on a table cell containing the text "ad.03.IL.R.nC.nOwn.Wait"
The HTML is:
<span onclick="javascript:showListMembers(343);" style="text-decoration:none; border-bottom: 1px solid Gray;">ad.03.IL.R.nC.nOwn.Wait</span>
What is the correct Watir statement?
matches = b.spans(:text => "ad.03.IL.R.nC.nOwn.Wait")
Use the plural method unless you're sure there's only one possible match. You can also do regex stuff
matches = b.spans(:text => /ad.03.IL.R.nC.nOwn.Wait/)
Span elements aren't table cells in the proper sense. Table cells don't normally have useful metatags

Does the width of a Table2 or a Cell2 include the border? For a Cell2, does it include the padding?

I'm working with the DynamicPDF library to typeset tabular data and I have an incomplete understanding of how the width property of Table2 and Cell2 objects works. Specifically, I don't know whether the width set by the property is an internal width, or an external one. For a Table2 object, I don't know whether it includes the left and right borders of the table. For a Cell2 object, I don't know whether it includes the left and right borders or whether it includes the left and right padding. For that matter, I have an incomplete understanding of why we are permitted to set the width of the table at all - surely the width follows logically from the widths of the table columns, in which case the proper way to modify the table's width is by modifying the column widths?
It would be useful to know whether the table width in particular includes its borders, because I want to typeset tables that are the width of the page (or rather, the width of the area inside the page margins). If the Table2's width propery includes the border width, then the correct way to do this is to set the width to the page width. If not, then the correct way is to subtract the left and right border widths first. If I do it wrong, then the table will be either too wide or too narrow.
These pages seem to be up-to-date documentation, but they don't specify whether the borders/padding are included (they just say "Gets or sets the width of the table." and "Gets the width of the cell.") This page has examples of use of the Table2 class, but all of them use hard-coded widths.
The table width is independent of column widths. Table width cannot be modified by modifying the column widths. When generating the tables with dynamic data, setting table width allows you to specify a region in which the content is rendered and anything that falls outside of these boundaries is overflowed into a new table. For example if the sum of the column widths is greater than the table width, the columns that do not fall within the table boundaries are pushed out into the overflow table which can be accessed using GetOverflowColumns().
Border width is not included in the table width. On the other hand, cell width includes the cell border width and padding of the cell. Here is the code that demonstrates how different widths are set.
Document document = new Document();
Page page = new Page();
Table2 table = new Table2(0, 0, 300, 500);
table.Border.Width = 5;
table.Border.Color = RgbColor.Red;
table.Columns.Add(100);
table.Columns.Add(100);
table.Columns.Add(100);
Row2 row = table.Rows.Add();
Cell2 cell = row.Cells.Add("Cell 1");
cell.Padding = 5;
cell.Border.Width = 5;
cell.Border.Color = RgbColor.Blue;
Cell2 cell2 = row.Cells.Add("Cell 2");
cell2.Padding = 5;
cell2.Border.Width = 5;
cell2.Border.Color = RgbColor.Green;
Cell2 cell3 = row.Cells.Add("Cell 3");
cell3.Padding = 5;
cell3.Border.Width = 5;
cell3.Border.Color = RgbColor.DarkOrange;
page.Elements.Add(table);
page.Elements.Add(new LayoutGrid());
page.Elements.Add(new Label("Table Width: " + table.Width.ToString(), 0, 50, 200, 20));
document.Pages.Add(page);
document.Draw("Table2.pdf");
Disclaimer: I work for ceTe Software, the company that develops DynamicPDF libraries.

Resources