I'm using REXX on a PC to convert a tab delimited table to HTML. The REXX code identifies rows, cells and columns that vary in location from one table to the next but which require rotation, bold highlighting, and either light blue, light gray or no filler. All of this is working, but the size of the tables could be reduced if there is a way to indicate a count of duplicate <td></td> entries in a given row.
The output has predefined XML code which defines an Excel sheet and is followed by the table. The table is two-dimensional. By this I mean the top row lists attributes and the left column lists entities which may have some, but not necessarily all, of the attributes. At the intersection of an attribute column and entity row the cell may contain one of several values, including a space. Some rows may be 50 or more cells long and contain a value only in the 48th column.
In this example, when I build that row, I have 50 combinations of <td></td>. In the case of empty columns from 2 through 47 I need to repeat that empty <td></td> 46 times to assure the cell with a value is shown under the correct attribute. Some tables may have 10,000 rows.
Does HTML have a repeat counter? Perhaps something like this:
<r c=46><td></td></r>where <r indicates a need to repeat and must contain "c=" for the repeat count of <td></td> and of course a closing </r>.
A repeat counter would reduce load and transmit time as well as the size of the HTML file.
There is no "repeat" counter, however, you could use "colspan" instead of adding 46 <td></td>.
Example:
<tr><td colspan="46"><td></tr>
Related
Evidently, HTMLTableRow.prototype.cells property allows one to get an array of cells that a table row element contains as its children. But for tables which contain cells that span multiple rows, retrieving cells that can be said to "naturally" apply to that row, becomes a non-trivial operation, especially for tables of arbitrary layout (meaning one where you can't assume some known row span for all of its cells).
Am I right in that I would have to design an algorithm myself for retrieving cells that would naturally belong in a row, as described? To explain what I mean by "naturally belong", consider first the following table with two cells that span two rows each:
<table>
<tbody>
<tr><td>A</td><td>B</td><td>C</td><td rowspan="2">D</td></tr>
<tr><td>E</td><td rowspan="2">F</td><td>G</td></tr>
<tr><td>H</td><td>I</td><td>J</td></tr>
</tbody>
</table>
I would like to know, for example, which cell values naturally -- as rendered -- belong to the second row. For the above table as table, the expression table.rows[1].cells evaluates to an array of 3, not 4 table cell elements. It seems to merely mirror the amount of children for the row element, no more no less (table.rows[1].children is also a collection of the same 3 elements). That does not express that the cell denoted "D" also applies to the second row, which beget my question -- how to compute the collection of cells that belong to a given row?
Now, I am not saying that what the cells property lets me retrieve is wrong in any way, mind you, just that I need a different view on which cells belong to a row.
For example, for the second row, such "view" would be the ordered collection of cells denoted "E", "F", "G" and "D", since "D" spans to the end of the second row and thus can be said to naturally apply to that row as well.
Is there such an API that would allow me to compute such views, or in the worst case some third party library?
I've used alternate table row shading before (using the ::nth-child selector), but I noticed it can't get the job done when you have irregular table structure. I've come across one specific case for which I'd like to come up with a solution.
In the picture below, you can see that the rows are styled with ::nth-child(even) to give every other row a background color:
The problem here is that in some cases, the first column cell spans two rows, causing the rest of the cells in that "row" (which is really two rows) to appear disjointed or misaligned. The cells in the rows spanned by "Cole" should have the same background color as the first column's cell, because the following columns are all related to the first one. Is this achievable using strictly CSS?
I would just change the structure of the table, but the people entering this content are using a CMS with a built-in text editor, and they have no control over the format. I'd have to manually change every table on their site, which would be a huge undertaking (and it wouldn't account for future tables).
I have a form which consists of a table. The table is generated with an iterator over a java collection. The elements which are generated on each iteration are:
<tr>
<th>Element name</th>
<td>Element value</td>
</tr>
The table and /table tags are outside the iterator obviously.
The problem is that I need to have the table in two columns, in some cases.
Something like this: http://jsfiddle.net/S32p2/
Is it possible to achieve this without the use of nested tables?
What makes it complicated for me, is that sometimes there are no fields at all, sometimes there should be one column and sometimes there should be two, based on the elements which are iterated over.
Also I am aware of this question: How to have one html table split into two sections, side by side?
The problem is that I don't want the columns to be based on some predetermined length, but the second column should be made based on the values iterated over, as already mentioned earlier.
How would I set a maximum lines to display in a BO 4 report? On each page, I'd like to show 20 account numbers in column 1 with item counts in the next columns. There are some good discussions on limiting the rows retrieved in a query (e.g., Limit number of result or rows returned in BO using WebI). Some suggestions include using sections with RowIndex()/20 to limit the lines to 20, so I tried adding a variable =Floor(RowIndex()/20). However, the lines in my report contain aggregated variables, and the row index counts all records retrieved. Thoughts?
One option:
Add a column on the far left of the block. Use the following formula:
=Floor(RunningCount([Account Number])/10)
(assuming, of course, that your dimension is named [Account Number])
Create a break on this column. (Report Element -> Table Layout -> Break -> Add Break). Go back to the same menu and click Manage Breaks. Click the "Start on a new page" checkbox.
This will create a block with a maximum of 20 rows per page. Unfortunately, there's no direct way to hide a column in WebI, so you'd be stuck with this ugly column. What you can do, however, is remove all borders, change the font to white-on-white, and reduce its width as much as possible.
I'm curious what the impact is of colspan in different browsers.
I have a table with a row acting as a heading which uses colspan to spread across all columns, and I might want to add columns in the future. If I simply make the colspan some really large number so that I can add columns without having to update the heading, does this have any negative impacts?
Will browsers behave badly and creating loads of dud columns, or should they be smart enough to limit this to how many columns the table actually has?
Using colspan to span columns that have no cells beginning in them violates the HTML table model (which is being formalized in HTML5 table processing model). All bets are off then, and testing on all existing browsers (which isn’t really possible) wouldn’t be enough – future browsers could handle your markup error differently.
Theoretically, according to HTML 4.01, colspan=0 means that “the cell spans all columns from the current column to the last column of the column group (COLGROUP) in which the cell is defined”. However, this was not implemented, and it is being removed (value of 0 made an error) in HTML5, without any replacement.
The idea is clearly that the author, or the software that generates an HTML document, is responsible for counting the columns. That is, if you add columns to the table, you need to modify the colspan value, if you want a cell to span all columns.
MDN says there are two behaviors, one for <th> and one for <td>.
For header cells (th), the value must be >=0, <=1000. If it is >1000 it clips to 1000, if it is 0 it spans the entire <colgroup>.
For data cells (td), the value value must be >= 0, <= 1000. If it is >1000 it is set to 1, if it is 0 it spans the entire <colgroup>.
Also, it appears Firefox is the only one to support the 0 = colgroup rule.
Best way is to try it. But my guess is they'll all be fine.
What's a really large number? 50? 100? 10000?
here's a fiddle with 200 columns and a colspan:
<table>
<tr>
<th colspan="200">test</th>
</tr>
<tr>
<td>test</td>
...
</tr>
</table>
http://jsfiddle.net/FYKqb/
try it in different browsers. I reckon they'd all be fine.