Table

This attribute allows to specify an arbitrary tabular data in the context of assembly.

../../../../_images/table_img1.png

Example of a table in the page management UI

In the this example we could use the following markup:

<html>
<body>
<h1>${asm('title')}</h1>

$!{asm('parrots').asTable.toHtml()}
#set(Table parrots = asm('parrots'))

<br>Glasha parrot kind: ${parrots.find('Glasha')}
<br>Glasha age: ${parrots.find('Glasha', 2)}

</body>
</html>

And we get:

../../../../_images/table_img2.png

In this markup the expression $!{asm(‘parrots’).asTable.toHtml()} outputs a table as html. Then, ${parrots.find(‘Glasha’) outputs the second column of the row, where the value of the first column is equal to the passed attribute Glasha.

Use of table attributes in a page markup.

Table attribute UI

Table toolbar:

../../../../_images/table_img3.png
Element UI Description
../../../../_images/table_img4.png Adds a new row to the table
../../../../_images/table_img5.png Removes selected rows
../../../../_images/table_img6.png Specifies the number of columns in the table

com.softmotions.ncms.mhttl.Table

String Table.find(firstColVal[, String def])

Search the row in a table with the first column value equals to firstColVal. If the row is found the second column value of the row is returned.

Arguments:
  • def (String) – The value if the row is not found; by default null.
String Table.find2(firstColVal[, String def])

Search the row in a table with the first column value equals to firstColVal. If the row is found the third column value of the row is returned.

Arguments:
  • def (String) – The value if the row is not found; by default null.
String Table.find2(firstColVal[, String def])

Search the row in a table with the first column value equals to firstColVal. If the row is found the forth column value of the row is returned.

Arguments:
  • def (String) – The value if the row is not found; by default null.
String Table.find(String firstColVal[, int colIndex][, String def])

Search the row in a table with the first column value equals to firstColVal. If the row is found it returns the value of the cell in the row with a colIndex index.

Arguments:
  • firstColVal (int) – Column index, where the value is found. By default, 1 (Second column by indexing from 0).
  • def (String) – The value returned if the row is not found, by default null.
String Table.toHtml([Map<String,?> params]):()

Returns the current table as the html markup.

Example the table with css class wide but without headers:

${asm('table').toHtml(['noHeader':true, 'tableAttrs':'class="wide"'])}

The optional method params may contain the following pairs:

  • NoEscape => Boolean | String - don’t escape of table cells values. By default false.
  • NoHeader => Boolean | String do not display the first row as a table header. By default false.
  • TableAttrs => String Additional table attributes.
Arguments:
  • params (Map<String,?>) – Optional settings of the html table generation.