ncolumntable or HTML table

Hi,

which is the best practice in terms of creating a table?

Is it ncolumntable or html table?

 

Thanks and Regards

Rohini

  Discussion posts and replies are publicly visible

Parents
  • I will generally use ncolumntable() for a quick implementation when formatting is not necessary and column counts are low (ex. task history in email notifications). However, note this function is restrictive on columns (10) and formatting. For bigger and prettier HTML tables, such as in output documents from template, I will create the HTML manually which allows unlimited columns and formatting. In this example, the CSS classes are built into the HTML template and added via the rules.

    rule!createHtmlTable()

    with(
    local!data: rule!getData_qr(ri!id,a!pagingInfo(1,-1),
    local!columnNames: {"Employee","Supervisor","Division","Location","Company","Department"},

    "<table class='TableStyle'>" &
    "<tr>" & joinarray(apply(rule!tableCell(tdClass: "TableHeader", item: _),local!columnNames),"") & "</tr>" &
    joinarray(apply(rule!tableRow,
    merge(
    {index(local!data.data,"employeeName",{})},
    {index(local!data.data,"supervisorName",{})},
    {index(local!data.data,"division",{})},
    {index(local!data.data,"location",{})},
    {index(local!data.data,"company",{})},
    {index(local!data.data,"department",{})}
    )
    ),"") &
    "</table>"
    )

    rule!tableCell()

    ="<td class='" & ri!tdClass & "'>" & ri!item & "</td>"

    rule!tableRow()

    ="<tr>" &
    joinarray(
    apply(rule!tableCell(tdClass: "TableStyle", item: _),
    {
    ri!col1,ri!col2,ri!col3,ri!col4,ri!col5,ri!col6
    }
    ),""
    ) &
    "</tr>"
Reply
  • I will generally use ncolumntable() for a quick implementation when formatting is not necessary and column counts are low (ex. task history in email notifications). However, note this function is restrictive on columns (10) and formatting. For bigger and prettier HTML tables, such as in output documents from template, I will create the HTML manually which allows unlimited columns and formatting. In this example, the CSS classes are built into the HTML template and added via the rules.

    rule!createHtmlTable()

    with(
    local!data: rule!getData_qr(ri!id,a!pagingInfo(1,-1),
    local!columnNames: {"Employee","Supervisor","Division","Location","Company","Department"},

    "<table class='TableStyle'>" &
    "<tr>" & joinarray(apply(rule!tableCell(tdClass: "TableHeader", item: _),local!columnNames),"") & "</tr>" &
    joinarray(apply(rule!tableRow,
    merge(
    {index(local!data.data,"employeeName",{})},
    {index(local!data.data,"supervisorName",{})},
    {index(local!data.data,"division",{})},
    {index(local!data.data,"location",{})},
    {index(local!data.data,"company",{})},
    {index(local!data.data,"department",{})}
    )
    ),"") &
    "</table>"
    )

    rule!tableCell()

    ="<td class='" & ri!tdClass & "'>" & ri!item & "</td>"

    rule!tableRow()

    ="<tr>" &
    joinarray(
    apply(rule!tableCell(tdClass: "TableStyle", item: _),
    {
    ri!col1,ri!col2,ri!col3,ri!col4,ri!col5,ri!col6
    }
    ),""
    ) &
    "</tr>"
Children
No Data