JSF:
...
xmlns:t="http://myfaces.apache.org/tomahawk">
<t:panelGrid columns="4">
...
</t:panelGrid>
It dynamically generates plain old HTML table with tr's and td's elements.
How can I set specific css styles for these tr and/or td elements?
Use columnClasses and rowClasses attributes to give each cell a unique class
For example:
<t:panelGrid columns="4" columnClasses="a,b,c,d" rowClasses="x,y,z">
</t:panelGrid>
columnClasses
The columnClasses attribute accepts a comma-delimited list of CSS style classes that will be applied to the columns of the table. Style classes for an individual column may also be defined in a space separated list. A style class is applied to a table column as the value for the class attribute of rendered td or th element.
The algorithm used to apply the CSS style classes to the table columns is simple. In the table rendering process, style classes are applied to columns one at a time until (a) there are no more columns to display or (b) there are no more style classes to apply.
* If (a) happens at the same time as (b), the next row in the table is rendered.
* If (a) happens before (b), the remaining style classes are ignored.
* If (b) happens before (a), the remaining columns will not have style classes.
rowClasses
The rowClasses attribute accepts a comma-delimited list of CSS style classes to be applied to the rows of the table. Style classes for an individual row may also be defined in a space separated list. A style class is applied to a table row as the value for the class attribute of rendered tr element.
Style classes are applied to rows in the same order that they are defined. For example, if there are two style classes, the first is applied to the first row, the second is applied to the second row, the first is applied to the third row, the second is applied to the fourth row, and so on. The list of styles is looped over from the beginning until there are no more rows to display.
In my standard JSF Project (Mojarra 2.0.3)
This tag generates:
<h:panelGrid border="1"
columns="4"
columnClasses="a,b,c,d"
rowClasses="x,y,z">
<h:outputText value="ax"/>
<h:outputText value="bx"/>
<h:outputText value="cx"/>
<h:outputText value="dx"/>
<h:outputText value="ay"/>
<h:outputText value="by"/>
<h:outputText value="cy"/>
<h:outputText value="dy"/>
<h:outputText value="az"/>
<h:outputText value="bz"/>
<h:outputText value="cz"/>
<h:outputText value="dz"/>
</h:panelGrid>
This HTML:
<table border="1">
<tbody>
<tr class="x">
<td class="a">ax</td>
<td class="b">bx</td>
<td class="c">cx</td>
<td class="d">dx</td>
</tr>
<tr class="y">
<td class="a">ay</td>
<td class="b">by</td>
<td class="c">cy</td>
<td class="d">dy</td>
</tr>
<tr class="z">
<td class="a">az</td>
<td class="b">bz</td>
<td class="c">cz</td>
<td class="d">dz</td>
</tr>
</tbody>
</table>
Related
I am trying to add a custom record type sublist on a Bill of Materials Advanced PDF template.
I copied the code format for item table and change it with the id of the custom record type. I was able to save the PDF template without error. However, only the standard Items sublist are showing, and my custom record sublist is not showing on the printed PDF.
Here are the ids of the custom record type and its fields applied to the work order transaction.
I have also set the custom record type to be a child record of the work order parent transaction.
Custom Record Type: Solvent Add Back (id=customrecord_solvent_add_back)
Fields:
Solvent Add Back Parent [List/Record=Transaction, Record is Parent=YES] (custrecord_solvent_add_back_parent)
Solvent Item (custrecord_solvent_item)
Solvent Quantity (custrecord_solvent_quantity)
Unit (custrecord162)
Solvent Batch Number (custrecord_solvent_batch_number)
<#if record.custrecord_solvent_add_back_parent?has_content>
<table style="width: 100%; margin-top: 10px;">
<thead>
<tr>
<th colspan="5" style="font-size:14px;">Solvent Item</th>
<th align="right" colspan="3" style="font-size:14px;">Qty.</th>
<th align="right" colspan="3" style="font-size:14px;">Unit</th>
<th align="right" style="width: 143px;font-size: 14px;">Batch Number</th>
</tr>
</thead>
<#list record.custrecord_solvent_add_back_parent as item>
<tr>
<td colspan="5" style="font-size:14px;">${item.custrecord_solvent_item}</td>
<td align="right" colspan="3" style="font-size:14px;">${item.custrecord_solvent_quantity}</td>
<td align="right" colspan="3" style="font-size:14px;">${item.custrecord162}</td>
<td align="right" style="width: 143px;font-size: 14px;">${item.custrecord_solvent_batch_number}</td>
</tr>
</#list></table></#if>
I am fairly new to Advanced PDF/HTML source code editing product area with less than 2 months of experience. But has more than 4 years of NetSuite experience.
Thanks in advance for all your help.
As far as i know, its not possible to have child record/custom record data in Advanced PDF. Better go with a suitelet.
I have a suitelet in which in run html code having an html table. I have given checkbox to the table. I wanted to retrieve number of lines and values in table which are checked after I click Submit on Suitelet. However, I only get one value of checkbox and not how many lines I have set the checkbox true.
<table>
<tbody>
<tr>
<td>
<input type="checkbox" class="select-items" name="selectitem" id="selectitem">
</td>
</tr>
<tbody>
<table>
I'm trying to parse tables from lots of html pages. Each tagret table has next structure:
<table width="100%%" border="2" bordercolor="navy">
<tr bordercolor="#0000FF">
<td width="20%%" height="22" bgcolor="navy"><font color="#FFFFFF"><b>Field1</b></font></td>
<td width="20%%" height="22" bgcolor="navy"><font color="#FFFFFF"><b>Field2</b></font></td>
<td width="60%%" height="22" bgcolor="navy"><font color="#FFFFFF"><b>Field3</b></font></td>
</tr>
<tr>
<td width="12%">A1</td>
<td width="32%">A2</td>
<td width="56%">A3</td>
</tr>
<tr>
<td width="12%">B1</td>
<td width="32%">B2</td>
<td width="56%">B3
</td>
</tr>
<tr>
<td width="12%">C1</td>
<td width="32%">C2</td>
<td width="56%">C3</td>
</tr>
<tr>
<td width="12%">D1</td>
<td width="32%">D2</td>
<td width="56%">D3</td>
</tr>
</table>
Number of rows varies from page to page, so parser should be able to work for any number of rows. I would like to collect info from each html page like
A1 A2 A3
B1 B2 B3
C1 C2 C3
D1 D2 D3
How can I do that?
You can use find_all() and get_text() to gather the table data. The find_all() method returns a list that contains all descendants of a tag; and get_text() returns a string that contains a tag's text contents. First select all tabes, for each table select all rows, for each row select all columns and finally extract the text. That would collect all table data in the same order and structure that it appears on the HTML document.
from bs4 import BeautifulSoup
html = 'my html document'
soup = BeautifulSoup(html, 'html.parser')
tables = [
[
[td.get_text(strip=True) for td in tr.find_all('td')]
for tr in table.find_all('tr')
]
for table in soup.find_all('table')
]
The tables variable contains all the tables in the document, and it is a nested list that has the following structure,
tables -> rows -> columns
If the structure is not important and you only want to collect text from all tables in one big list, use:
table_data = [i.text for i in soup.find_all('td')]
Or if you prefer CSS selectors:
table_data = [i.text for i in soup.select('td')]
If the goal is to gather table data regardless of HTML attributes or other parameters, then it may be best to use pandas. The pandas.read_html() method reads HTML from URLs, files or strings, parses it and returns a list of dataframes that contain the table data.
import pandas as pd
html = 'my html document'
tables = pd.read_html(html)
Note that pandas.read_html() is more fragile than BeautifulSoup and it will raise a Value Error if it fails to parse the HTML or if the document doesn't have any tables.
I have 13 columns in a table. When I display it in a <h:dataTable>, then it expands to a very wide area on the page.
Is there any way to minimize their width or to display some columns above and some columns below?
You can use h:dataTable's columnClasses attribute to set width of columns.
From the Java EE tutorial:
If columnClasses or rowClasses
specifies more than one style, the
styles are applied to the columns or
rows in the order that the styles are
listed in the attribute. For example,
if columnClasses specifies styles
list-column-center and
list-column-right and if the table has
two columns, the first column will
have style list-column-center, and the
second column will have style
list-column-right.
You can define styles for different widths and assign these styles to your columns. Here is an example:
<h:dataTable id="items"
columnClasses="list-column-center, list-column-left,
list-column-right, list-column-center">
...
</h:dataTable>
And in your css file:
.list-column-center{ width: 300px; }
.list-column-left{ width: 100px; }
If you want to display columns in rows you can use for example two datatables in a panelGrid:
<h:panelGrid columns="1">
<h:dataTable value=#{myBean.myTable} var="item">
<h:column>#{item.column1}</h:column>
...
</h:dataTable>
<h:dataTable value=#{myBean.myTable} var="item">
<h:column>#{item.column2}</h:column>
...
</h:dataTable>
</h:panelGrid>
I have a simple JSF datatable, which currently has four columns, one header row and (with current data) three data rows.
I have to add three extra columns; that part's easy.
I also want to add another header row before the existing header row with headers that span a subset of the columns.
The desired result is something like:
Column 1: first row empty; header on second row.
Columns 2-4: first row header spans 3 columns; second row has individual column headers.
Columns 5-7: first row header spans 3 columns; second row has individual column headers.
Is this possible? If so, how do I do it?
Following are images showing what it should look like.
This is the data table before I've changed anything.
Table Example 1 http://www.isw.com.au/home/sjleis/stuff.nsf/tableexample1.gif
This is the data table after I've added three columns. I was able to do this easily.
Table Example 1 http://www.isw.com.au/home/sjleis/stuff.nsf/tableexample2.gif
This shows the desired end result, which I can't figure out. Note the "Retail Sales" and "Fleet/Gov Sales" headers each span three columns.
Table Example 1 http://www.isw.com.au/home/sjleis/stuff.nsf/tableexample3.gif
This would be easy if you were using Richfaces (as Bozho mentions) with the breakBefore attribute.
Here's a quick example:
<rich:dataTable value="#{countryCodeListFactory}" var="c">
<f:facet name="header">
<rich:columnGroup>
<rich:column colspan="2">Main</rich:column>
<rich:column colspan="4">Other Details</rich:column>
<rich:column breakBefore="true">Country ID</rich:column>
<rich:column>Name</rich:column>
<rich:column>Region</rich:column>
<rich:column>Alpha</rich:column>
<rich:column>ISO</rich:column>
<rich:column>Flag Path</rich:column>
</rich:columnGroup>
</f:facet>
<rich:column>#{c.countryId}</rich:column>
<rich:column>#{c.countryName}</rich:column>
<rich:column>#{c.region}</rich:column>
<rich:column>#{c.alpha3}</rich:column>
<rich:column>#{c.isoNum}</rich:column>
<rich:column>#{c.flagImage}</rich:column>
</rich:dataTable>
If you're not then hopefully you're using facelets. Then you can build the table manually using the <ui:repeat>
<table>
<tr>
<th colspan="2">Main</th>
<th colspan="4">Details</th>
</tr>
<tr>
<th>ID</th>
<th>Name</th>
<th>Region</th>
<th>Alpha</th>
<th>ISO</th>
<th>Flag</th>
</tr>
<ui:repeat value="#{countryCodeListFactory}" var="c">
<tr>
<td>#{c.countryId}</td>
<td>#{c.countryName}</td>
<td>#{c.region}</td>
<td>#{c.alpha3}</td>
<td>#{c.isoNum}</td>
<td>#{c.flagImage}</td>
</tr>
</ui:repeat>
</table>
You can't do this with <h:dataTable>. Well, you can with some ugly hacks, like modifying the DOM with javascript and adding the desired columns, but that's not what you should do.
Take a look at RichFaces dataTable - its columns support the colspan attribute.