Hi Community,
i have a requirement to create a html template using expression rule to create a table.
i am able to create a table but i am unable to generate borders for each row and headers. please prefer below code snippet.
TIA
Stefan Helzle
Discussion posts and replies are publicly visible
Just like you added style in table you can use border-bottom in the style tags of header (th) and row (tr). Below is an example
<table style="border:1px solid black;border-collapse: collapse;"> <th style="border-bottom:1pt solid black;">Fruit</th> <tr style="border-bottom:1pt solid black;"><td>Apple</td></tr> <tr style="border-bottom:1pt solid black;"><td>Mango</td></tr></table>
Hi Harsha,
Thanks for your response can you please do it in below code snippet i am getting error while doing the same.
It will be very helpful for me.
a!localVariables( local!dataDict:{ { name:"ABCD", age:25, company:"AS" }, { name:"QWER", age:27, company:"AT" }, { name:"SDFG", age:28, company:"Ay" } }, local!columns:{ { column: "name", width: 10}, { column: "age", width: 20}, { column: "company", width: 40} }, "<table style=""width:100%; border:1px solid black;border-collapse:collapse""> <tr>" & joinarray( a!forEach( local!columns, "<th style=""width:" & fv!item.width & "%"">" & fv!item.column & "</th>" ), "" ) & "</tr>" & joinarray( a!forEach( items: local!dataDict, expression: "<tr> <td>" & fv!item.name & "</td> <td>" & fv!item.age & "</td> <td>" & fv!item.company & "</td> </tr>" ), "" )&"</table>" )
What kind of error do you get?
You can try the below
a!localVariables( local!dataDict:{ { name:"ABCD", age:25, company:"AS" }, { name:"QWER", age:27, company:"AT" }, { name:"SDFG", age:28, company:"Ay" } }, local!columns:{ { column: "name", width: 10}, { column: "age", width: 20}, { column: "company", width: 40} }, "<table style=""width:100%; border:1px solid black;border-collapse:collapse""> <tr>" & joinarray( a!forEach( local!columns, "<th style=""width:" & fv!item.width & "%;border-bottom:1pt solid black"">" & fv!item.column & "</th>" ), "" ) & "</tr>" & joinarray( a!forEach( items: local!dataDict, expression: "<tr style=""border-bottom:1pt solid black""> <td>" & fv!item.name & "</td> <td>" & fv!item.age & "</td> <td>" & fv!item.company & "</td> </tr>" ), "" )&"</table>" )