Hi,
I am trying to create a table based on data from a dictionary object where certain values create a third column.
Here is an example of the table I am trying to achieve, where the Security group values are in a third column.
field | value | Security Group
==================================
name | John | SecGp 1
-------------------------------------------------------------
Job | jobless | SecGP 2
-------------------------------------------------------------
Tel | 0207123456 | SecGP 3
-------------------------------------------------------------
Mobile | 0743433845 |
-------------------------------------------------------------
Department | IT |
----------------------------------------------------
I've been trying to fathom it out. Below is my code. It puts the values in the field column, appending to the bottom of the table.
The items I want in the Security Group column begin with sg, dg, or pg.
Any help would be greatly Appreciated.
Many thanks
Woter
I am trying to create a table based on data from a dictionary object where certain values create a third column.
Here is an example of the table I am trying to achieve, where the Security group values are in a third column.
field | value | Security Group
==================================
name | John | SecGp 1
-------------------------------------------------------------
Job | jobless | SecGP 2
-------------------------------------------------------------
Tel | 0207123456 | SecGP 3
-------------------------------------------------------------
Mobile | 0743433845 |
-------------------------------------------------------------
Department | IT |
----------------------------------------------------
I've been trying to fathom it out. Below is my code. It puts the values in the field column, appending to the bottom of the table.
Code:
Function buildCommitTable()
Set oCmtDict=window.DialogArguments 'Retrieves dictionary object from collateForm() fuction.
table=document.getElementById("cmtTable").hasChildNodes
Set oTable = document.createElement("TABLE")
Set oTHead = document.createElement("<THEAD CLASS='tHead'>")
Set oTBody0 = document.createElement("TBODY")
Set oTBody1 = document.createElement("TBODY")
Set oTFoot = document.createElement("TFOOT")
Set oCaption = document.createElement("CAPTION")
Dim heading(2)
heading(0) = "Field"
heading(1) = "Value"
heading(2) = "Group Membership"
oTable.id="cmtTable"
oTable.appendChild(oTHead)
oTable.appendChild(oTBody0)
oTable.appendChild(oTBody1)
oTable.appendChild(oTFoot)
oTable.appendChild(oCaption)
oTable.border=1
Set oRow = document.createElement("TR")
oTHead.appendChild(oRow)
For Each h In heading
Set oCell = document.createElement("TH")
oCell.innerText = h
oRow.appendChild(oCell)
Next
'This section populates the table
For Each i In oCmtDict
Set oRow = document.createElement("<TR CLASS='rTable'>")
oTBody0.appendChild(oRow)
'For some reason, will not invert with <> or Not??
If Left(i,2) = "sg" Or _
Left(i,2) = "dg" Or _
Left(i,2) = "pg" Then
'Column 3 = Security Group
Set oCell = document.createElement("<TD CLASS='cSecGroup'>")
oCell.innerhtml = oCmtDict(i)
oRow.appendChild(oCell)
Else
'Column 1
Set oCell = document.createElement("<TD CLASS='cField'>")
oCell.innerhtml = i
oRow.appendChild(oCell)
'Column 2 = Group Name
Set oCell = document.createElement("<TD CLASS='cValue'>")
oCell.innerhtml = oCmtDict(i)
oRow.appendChild(oCell)
End If
Next
Set oCmtDict = Nothing
Set buildCommitTable = oTableContainer.appendChild(oTable)
End Function
The items I want in the Security Group column begin with sg, dg, or pg.
Any help would be greatly Appreciated.
Many thanks
Woter