How do I convert a flickity table using multiple tables into a single table - html-table

So I am having issues converting my responsive carousel table from individual tables to a single table, any help would be much appreciated.
<table class="table-head">
<thead>
<th>Head</th>
</thead>
<tbody>
<tr>
<td>Attr1</td>
</tr>
<tr>
<td>Attr2</td>
</tr>
<tr>
<td>Attr3</td>
</tr>
<tr>
<td>Attr4</td>
</tr>
</tbody>
</table>
<div class="table-scroll carousel">
<table class="carousel-cell">
<th>Title1</th>
<tr>
<td>11</td>
</tr>
<tr>
<td>12</td>
</tr>
<tr>
<td>13</td>
</tr>
<tr>
<td>14</td>
</tr>
</table>
<table class="carousel-cell">
<th>Title2</th>
<tr>
<td>21</td>
</tr>
<tr>
<td>22</td>
</tr>
<tr>
<td>23</td>
</tr>
<tr>
<td>24</td>
</tr>
</table>
<table class="carousel-cell">
<th>Title3</th>
<tr>
<td>31</td>
</tr>
<tr>
<td>32</td>
</tr>
<tr>
<td>33</td>
</tr>
<tr>
<td>34</td>
</tr>
</table>
<table class="carousel-cell">
<th>Title4</th>
<tr>
<td>41</td>
</tr>
<tr>
<td>42</td>
</tr>
<tr>
<td>43</td>
</tr>
<tr>
<td>44</td>
</tr>
</table>
</div>
To then turn it into something like this
<div class="table-scroll carousel">
<table class="table-head">
<tr class="carousel-cell">
<th>Date</th>
<td>2021</td>
<td>01 June</td>
<td>05 June</td>
<td>05 June</td>
<td>08 June</td>
<td>10 June</td>
<td>16 June</td>
<td>24 June</td>
<td>25 June</td>
<td>30 June</td>
<td>30 June</td>
<td>30 June</td>
<td>30 June</td>
<td> </td>
</tr>
<tr class="carousel-cell">
<th>Details</th>
<td> </td>
<td>Bal b/f</td>
<td>Cheque no 816078</td>
<td>Bank Giro credit</td>
<td>Bank Giro credit</td>
<td>Cheque no 816079</td>
<td>Direct debit</td>
<td>Bank charges</td>
<td>Direct debit</td>
<td>Cheque no 816081</td>
<td>SO payment</td>
<td>BACS payment</td>
<td>CHAPS payment</td>
<td>Interest</td>
</tr>
<tr class="carousel-cell">
<th>Debit</th>
<td>£</td>
<td> </td>
<td>800</td>
<td> </td>
<td> </td>
<td>1,864</td>
<td>700</td>
<td>52</td>
<td>400</td>
<td>1,290</td>
<td>300</td>
<td>100</td>
<td>70</td>
<td> </td>
</tr>
<tr class="carousel-cell">
<th>Credit</th>
<td>£</td>
<td> </td>
<td>2,000</td>
<td>2,500</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td>20</td>
</tr>
<tr class="carousel-cell">
<th>Balance</th>
<td>£</td>
<td>8,196 C</td>
<td>7,396 C</td>
<td>9,396 C</td>
<td>12,896 C</td>
<td>11,032 C</td>
<td>10,332 C</td>
<td>10,280 C</td>
<td>9,880 C</td>
<td>8,590 C</td>
<td>8,290 C</td>
<td>8,190 C</td>
<td>8,120 C</td>
<td>8,140 C</td>
</tr>
</table>
</div>
The CSS for both looks like this
.table-head {
float: left;
width: 80px;
border-right: 2px solid #333;
border-collapse: collapse
}
.table-scroll {
float: left;
width: calc(100% - 81px);
border-top: 1px solid #333;
border-right: 1px solid #333;
border-bottom: 1px solid #333;
background-color: #AAA;
}
.table-scroll table {
margin-top: -1px;
width: 30%;
min-width: 300px;
max-width: 40%;
border-collapse: collapse;
}
th {
text-align: left;
background-color: #f2f2f2;
color: #0076BF;
}
th, td {
padding: 10px;
border: 1px solid #333;
background-clip: padding-box;
}
td {
background-color: #fff;
}
And the flickity config
var elem = document.querySelector('.carousel');
var flkty = new Flickity( elem, {
// options
freeScroll: true,
contain: true,
prevNextButtons: false,
groupCells: true,
cellAlign: 'left'
});
Both are displayed on codepen, multiple tables https://codepen.io/joshuaserpis/pen/ZEojLKR
Single table https://codepen.io/joshuaserpis/pen/oNoOgYN

Related

CASE expression to Replace NULLs with strings in SQL confusion [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 days ago.
This post was edited and submitted for review 9 days ago.
Improve this question
I have 2 columns one is complete and the second one includes missing values as NULL
Like this
table, th, td {
border: 0.4px solid black;
}
table {
width: 50%;
}
th {
height: 30px;
}
<table>
<tr>
<th>column1</th>
<th> column2</th>
</tr>
<tr>
<td>late fee</td>
<td> X</td>
</tr>
<tr>
<td>billing disbute</td>
<td> Y</td>
</tr>
<tr>
<td>transiction issue</td>
<td> NULL</td>
</tr>
<tr>
<td>late fee</td>
<td>NULL</td>
</tr>
<tr>
<td>billing disbute</td>
<td>Y</td>
</tr>
<tr>
<td>transiction issue</td>
<td>X</td>
</tr>
<tr>
<td>billing disbute</td>
<td>NULL</td>
</tr>
<tr>
<td>late fee</td>
<td>X</td>
</tr>
</table>
I checked and each distinct value of column1 has either X or Y in column2
So my approach was to create a table include distinct values of column1 and column2 excluding NULLs
AS in this query
SELECT DISTINCT coulmn1, column2
FROM db
WHERE column2 IS NOT NULL
table, th, td {
border: 0.4px solid black;
}
table {
width: 50%;
}
th {
height: 30px;
}
<table>
<tr>
<th>column1</th>
<th> column2</th>
</tr>
<tr>
<td>billing disbute</td>
<td>Y</td>
</tr>
<tr>
<td>transiction issue</td>
<td>X</td>
</tr>
<tr>
<td>late fee</td>
<td>X</td>
</tr>
</table>
THEN use REPLACE function nested in a CASE expression with 2 conditions
This is the query I used
WITH t2 AS (
SELECT DISTINCT coulmn1, column2
FROM db
WHERE column2 IS NOT NULL )
SELECT db.column1,
CASE WHEN db.column2 IS NULL AND db.column1 = t1.column1
THEN REPLACE ('column2', 'NULL', 't2.column2') END
FROM db, t2
And I was expecting something like this table with no NULL
table, th, td {
border: 0.4px solid black;
}
table {
width: 50%;
}
th {
height: 30px;
}
<table>
<tr>
<th>column1</th>
<th> column2</th>
</tr>
<tr>
<td>late fee</td>
<td> X</td>
</tr>
<tr>
<td>billing disbute</td>
<td> Y</td>
</tr>
<tr>
<td>transiction issue</td>
<td> X</td>
</tr>
<tr>
<td>late fee</td>
<td>X</td>
</tr>
<tr>
<td>billing disbute</td>
<td>Y</td>
</tr>
<tr>
<td>transiction issue</td>
<td>X</td>
</tr>
<tr>
<td>billing disbute</td>
<td>Y</td>
</tr>
<tr>
<td>late fee</td>
<td>X</td>
</tr>
</table>
The issue is this query replaced all values in column2 to NULLs
which the complete opposite of what it supposed to do
and the output was like this instead
table, th, td {
border: 0.4px solid black;
}
table {
width: 50%;
}
th {
height: 30px;
}
<table>
<tr>
<th>column1</th>
<th> column2</th>
</tr>
<tr>
<td>late fee</td>
<td>NULL</td>
</tr>
<tr>
<td>billing disbute</td>
<td>NULL</td>
</tr>
<tr>
<td>transiction issue</td>
<td> NULL</td>
</tr>
<tr>
<td>late fee</td>
<td>NULL</td>
</tr>
<tr>
<td>billing disbute</td>
<td>NULL</td>
</tr>
<tr>
<td>transiction issue</td>
<td>NULL</td>
</tr>
<tr>
<td>billing disbute</td>
<td>NULL</td>
</tr>
<tr>
<td>late fee</td>
<td>NULL</td>
</tr>
</table>

How to create html table with subcolumns group?

I want to make a table in html that will be like this:
<style>
BODY { color: black; background-color: white; font-family: Verdana, Arial, Helvetica; font-size: 80% }
TH { font-size: 80% }
TD { font-size: 80% }
TD.Layout { background-color: white}
TH.Title { background-color: #A0E0A0}
TD.Item { background-color: #E8E8E8}
</style>
<TABLE border ="1" cellspacing ="2" cellpadding ="6">
<TR>
<TH class="Title" rowspan = 2>Name</TH>
<TH class="Title" align="center" colspan = 2>2017 statistics</TH>
<TH class="Title" align="center" colspan = 2>2018 statistics</TH>
</TR>
<TR>
<TH class="Title" align="center">Value 1</TH>
<TH class="Title" align="center">Value 2</TH>
<TH class="Title" align="center">Value 1</TH>
<TH class="Title" align="center">Value 2</TH>
</TR>
<TR>
<TH class="Title" align="center">John</TH>
<TD class="Item" align="center">1</TD>
<TD class="Item" align="center">2</TD>
<TD class="Item" align="center">3</TD>
<TD class="Item" align="center">4</TD>
</TR>
<TR>
<TH class="Title" align="center">George</TH>
<TD class="Item" align="center">5</TD>
<TD class="Item" align="center">6</TD>
<TD class="Item" align="center">7</TD>
<TD class="Item" align="center">8</TD>
</TR>
</TABLE>
The point is that in every year there will be 5 or 6 subcolumns and I want to group them somehow in order to be easier for somebody to look at the table and understand which subcolumn belongs to every year without looking the header every time. A nice solution could be different border color for every year.
Two easy solutions that I can think of are:
Styling based on year.
<style>
BODY { color: black; background-color: white; font-family: Verdana, Arial, Helvetica; font-size: 80% }
TH { font-size: 80% }
TD { font-size: 80% }
TD.Layout { background-color: white}
TH.Title { background-color: #A0E0A0}
TD.Item { background-color: #E8E8E8}
.Year2017 {background-color: #145214}
.Year2018 {background-color: #000080}
</style>
<TABLE border ="1" cellspacing ="2" cellpadding ="6">
<TR>
<TH class="Title" rowspan = 2>Name</TH>
<TH class="Year2017" align="center" colspan = 2>2017 statistics</TH>
<TH class="Year2018" align="center" colspan = 2>2018 statistics</TH>
</TR>
<TR>
<TH class="Year2017" align="center">Value 1</TH>
<TH class="Year2017" align="center">Value 2</TH>
<TH class="Year2018" align="center">Value 1</TH>
<TH class="Year2018" align="center">Value 2</TH>
</TR>
<TR>
<TH class="Title" align="center">John</TH>
<TD class="Year2017" align="center">1</TD>
<TD class="Year2017" align="center">2</TD>
<TD class="Year2018" align="center">3</TD>
<TD class="Year2018" align="center">4</TD>
</TR>
<TR>
<TH class="Title" align="center">George</TH>
<TD class="Year2017" align="center">5</TD>
<TD class="Year2017" align="center">6</TD>
<TD class="Year2018" align="center">7</TD>
<TD class="Year2018" align="center">8</TD>
</TR>
</TABLE>
CSS tooltip. Tooltip can represent the year and hence we don't need to look at header for year value.
For reference: https://www.w3schools.com/css/css_tooltip.asp

Colspan of 1.5 in a table

Is it possible with HTML/CSS to create a table with three columns, where one row has only two cells. However, instead of one cell of that row being 66% (colspan="2") and the other being 33%, both to be 50% (so errh, colspan="1.5" which doesn't work as expected)
To illustrate what I mean:
What I am talking about is the row which is in bold red, is this possible?
Sure, just like the following:
table,
td {
border: 1px solid #999;
}
td {
height: 20px;
width: 50px;
}
<table>
<tr>
<td></td>
<td colspan="2"></td>
<td></td>
</tr>
<tr>
<td></td>
<td colspan="2"></td>
<td></td>
</tr>
<tr>
<td colspan="2"></td>
<td colspan="2"></td>
</tr>
<tr>
<td></td>
<td colspan="2"></td>
<td></td>
</tr>
</table>
table,
td {
border: 1px solid #999;
}
td {
height: 20px;
width: 50px;
}
<table border="1" cellpadding="5" cellspacing="0">
<tr>
<td></td>
<td colspan="2"></td>
<td></td>
</tr>
<tr>
<td></td>
<td colspan="2"></td>
<td></td>
</tr>
<tr>
<td colspan="2"></td>
<td colspan="2"></td>
</tr>
<tr>
<td></td>
<td colspan="2"></td>
<td></td>
</tr>
</table>

Unable to switch control to a prompt with multiple fields in selenium

I am trying to select an element in the prompt, but I am unable to switch control to the prompt.
I've tried the below code:
Alert a = driver.switchTo().alert();
WebElement e = wait.until(Expected Conditions.visibilityofElementLocated(By.xpath("locator"));
Adding HTML code
<table role="dialog" aria-labelledby="ariaLabelledBy_promptsDlg" oncontextmenu="_CWprompts.eventCancelBubble(event);return false" border="0" cellspacing="0" cellpadding="0" id="promptsDlg" style="display: block; padding: 0px; visibility: visible; position: absolute; top: 119px; left: 368px; width: 800px; height: 400px; z-index: 1005;">
<tbody>
<tr>
<td style="width:800px;height:400px;" class="dialogbox" id="td_dialog_promptsDlg" onresize="_CWprompts.DialogBoxWidget_resizeIframeCB('promptsDlg',this)" valign="top">
<table class="dlgBox2" width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td height="0" valign="top">
<table style="height:26" class="dlgTitle" width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr valign="top" style="height:26px">
<td onselectstart="return false" ondragstart="return false" onmousedown="_CWprompts.DialogBoxWidget_down(event,'promptsDlg',this,false);return false;" style="cursor:move;padding-left:10px;" width="100%" valign="middle" align="left">
<nobr>
<span id="ariaLabelledBy_promptsDlg" class="titlezone">Prompts</span>
</nobr>
</td>
<td class="dlgCloseArea" align="left" valign="middle">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr style="height:26px">
<td valign="middle" align="left" style="padding-right:4px;">
<div id="helpIcon_promptsDlg" "="" title="Help Contents" class="imo" style="width:16px;height:16px;background-image:url('images/main/galleries/icon16x16gallery1b.png');background-position:0px -480px;"></div>
</td>
<td style="padding-right:10px">
<div id="dialogClose_promptsDlg" class="dlgCloseBtn" title="Close window"></div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
I am getting no such alert exception. Can someone please help me out with this?
Thanks in advance.

Two Rows in thead, Can't Set Column Widths in Second

I have a table with two rows of headings. I want to set the widths of some of the columns in the second row. I set up a Codepen to test it out. I find that if I remove the first row of headings, it takes the column widths I've specified without a problem. But with the first row of headings, it ignores the widths of the columns in the second row. :(
Please note that I have div's within the th's so I can style the borders.
Here's the Code:
body {
padding: 10px;
}
.data-table {
width: 100%;
border-spacing: 0 4px;
border-collapse: separate;
table-layout: fixed;
}/* Remove For SCSS*/
.title-11, .title-21 {
width: 40px;
}
.title-22 {
width: 100px;
}
.title-24 {
width: 100px;
}
thead tr th {
border-collapse: separate;
border-spacing: 0 5px;
}
.title {
/*
background: linear-gradient(to right, transparent 0%, #bbb 0%,
#bbb calc(100% - 10px),
transparent calc(100% - 10px)) 0 99% / 100% 1px
no-repeat;
*/
text-align: left;
padding-right: 10px;
}
.div-title {
border-bottom: 1px solid #bbb;
}
.hdr-field {
width: 150px;
}
tr .title:last-child {
padding-right: 0;
}
.side-title {
transform: rotate(-90deg);
width: 25px;
}
.fieldname {
width: 130px;
}
.fieldvalue.dest-data input[type=text] {
width: 100%;
}
.bodySection {
border-bottom: 10px solid #bbb;
margin-bottom: 10px;
}
tr {
// border-bottom: 10px solid #bbb;
}
/*}*//* For SCSS*/
<table class="data-table">
<thead>
<tr>
<th class="title-11"></th>
<th colSpan="2" class="title title-12">
<div class="div-title">Source</div>
</th>
<th colSpan="2" class="title title-13">
<div class="div-title">Destination</div>
</th>
</tr>
<tr>
<th class="title-21"></th>
<th colSpan="1" class="fieldname title title-22">
<div class="div-title hdr-field">Field</div>
</th>
<th colSpan="1" class="title title-23">
<div class="div-title">Value</div>
</th>
<th colSpan="1" class="fieldname title title-24">
<div class="div-title hdr-field">Field</div>
</th>
<th colSpan="1" class="title title-25">
<div class="div-title">Value</div>
</th>
</tr>
</thead>
<tbody class="bodySection">
<tr>
<td rowSpan="2" class="side-title">Name</td>
<td class="fieldname src-data">Short Name</td>
<td class="fieldvalue src-data"My Store/td>
<td class="fieldname dest-data">Short Name</td>
<td class="fieldvalue dest-data"><input type="text" value="My Store" /></td>
</tr>
<tr>
<td class="fieldname src-data">Long Name</td>
<td class="fieldvalue src-data"My Store/td>
<td class="fieldname dest-data">Long Name</td>
<td class="fieldvalue dest-data"><input type="text" value="My Store" /></td>
</tr>
</tbody>
<tbody class="bodySection">
<tr>
<td rowSpan="2" class="side-title">Name2</td>
<td class="fieldname src-data">Short Name2</td>
<td class="fieldvalue src-data"My Store/td>
<td class="fieldname dest-data">Short Name2</td>
<td class="fieldvalue dest-data"><input type="text" value="My Store2" /></td>
</tr>
<tr>
<td class="fieldname src-data">Long Name2</td>
<td class="fieldvalue src-data"My Store/td>
<td class="fieldname dest-data">Long Name2</td>
<td class="fieldvalue dest-data"><input type="text" value="My Store2" /></td>
</tr>
</tbody>
</table>
So just to clarify: the question is how to make the Field columns fixed width, while leaving the Value columns to find their own level.
Thank you.
I can't quite understand why and how table lay-outs are calculated, because the algorythm seems pretty complex.
However, you can achieve the desired lay-out by using a good ol' <colgroup>.
There's some not-too-hard to digest info about how to use them in the HTML4 spec | Calculating column width. Note that this also holds true for the new spec (col and colgroup are not deprecated).
Stick this in between <table> and <thead> in your fiddle:
<colgroup>
<col>
<col width="150">
<col>
<col width="150">
<col>
</colgroup>
DEMO working:
body {
padding: 10px;
}
.data-table {
width: 100%;
border-spacing: 0 4px;
border-collapse: separate;
table-layout: fixed;
}/* Remove For SCSS*/
.title-11, .title-21 {
width: 40px; /* Wont be applied */
}
.title-22 {
width: 100px; /* Wont be applied */
}
.title-24 {
width: 100px; /* Wont be applied */
}
thead tr th {
border-collapse: separate;
border-spacing: 0 5px;
}
.title {
/*
background: linear-gradient(to right, transparent 0%, #bbb 0%,
#bbb calc(100% - 10px),
transparent calc(100% - 10px)) 0 99% / 100% 1px
no-repeat;
*/
text-align: left;
padding-right: 10px;
}
.div-title {
border-bottom: 1px solid #bbb;
}
.hdr-field {
width: 150px;
}
tr .title:last-child {
padding-right: 0;
}
.side-title {
transform: rotate(-90deg);
width: 25px;
}
.fieldname {
width: 130px;
}
.fieldvalue.dest-data input[type=text] {
width: 100%;
}
.bodySection {
border-bottom: 10px solid #bbb;
margin-bottom: 10px;
}
tr {
// border-bottom: 10px solid #bbb;
}
/*}*//* For SCSS*/
<table class="data-table">
<colgroup>
<col width="40">
<col width="100">
<col>
<col width="100">
<col>
</colgroup>
<thead>
<tr>
<th class="title-11"></th>
<th colSpan="2" class="title title-12">
<div class="div-title">Source</div>
</th>
<th colSpan="2" class="title title-13">
<div class="div-title">Destination</div>
</th>
</tr>
<tr>
<th class="title-21"></th>
<th class="fieldname title title-22">
<div class="div-title hdr-field">Field</div>
</th>
<th class="title title-23">
<div class="div-title">Value</div>
</th>
<th class="fieldname title title-24">
<div class="div-title hdr-field">Field</div>
</th>
<th class="title title-25">
<div class="div-title">Value</div>
</th>
</tr>
</thead>
<tbody class="bodySection">
<tr>
<td rowSpan="2" class="side-title">Name</td>
<td class="fieldname src-data">Short Name</td>
<td class="fieldvalue src-data"My Store/td>
<td class="fieldname dest-data">Short Name</td>
<td class="fieldvalue dest-data"><input type="text" value="My Store" /></td>
</tr>
<tr>
<td class="fieldname src-data">Long Name</td>
<td class="fieldvalue src-data"My Store/td>
<td class="fieldname dest-data">Long Name</td>
<td class="fieldvalue dest-data"><input type="text" value="My Store" /></td>
</tr>
</tbody>
<tbody class="bodySection">
<tr>
<td rowSpan="2" class="side-title">Name2</td>
<td class="fieldname src-data">Short Name2</td>
<td class="fieldvalue src-data"My Store/td>
<td class="fieldname dest-data">Short Name2</td>
<td class="fieldvalue dest-data"><input type="text" value="My Store2" /></td>
</tr>
<tr>
<td class="fieldname src-data">Long Name2</td>
<td class="fieldvalue src-data"My Store/td>
<td class="fieldname dest-data">Long Name2</td>
<td class="fieldvalue dest-data"><input type="text" value="My Store2" /></td>
</tr>
</tbody>
</table>