PDA

Click to See Complete Forum and Search --> : Javascript


imbenet
May 12th, 2005, 11:55 AM
Hi,

I built tables dynamically. The first table contains parent rows with checkboxes. Each parent rows have a child table. The child table has checkboxes.
When you check/uncheck a row in the parent table it expands/collapses corresponding child table.
This works fine but I also want to able to uncheck all children rows when the parent row is collapsed.


Dim sClientPrefix = Replace(Me.UniqueID, ":", "_") & "_"
If Not IsNothing(oDT) Then
'Remove first row
oDT.Rows(0).Delete()

For iRow As Integer = 1 To oDT.Rows.Count - 1
'Load all Work centers
oTR = New TableRow
oTD = New TableCell
oChk = New CheckBox
oChk.Text = oDT.Rows(iRow)("Name")
oChk.ID = "chk_wc_" & oDT.Rows(iRow)("WorkCenterID").ToString
oChk.Checked = Request(oChk.ID) = "on"

Dim sScript As String = sClientPrefix & "tb_WorkCenter_" & _
oDT.Rows(iRow)("WorkCenterID").ToString.Replace("-", "") & ".style.display = this.checked? 'block' : 'none';"
sScript &= ""

oChk.Attributes.Add("onclick", sScript)
oChk.AutoPostBack = False
oTD.Controls.Add(oChk)

oTR.Cells.Add(oTD)
oTR.BackColor = Color.Beige
oTR.Width.Percentage(100)
tbWorkCenter.Rows.Add(oTR)

'Check if user is part of work center
oDV.RowFilter = "WorkCenterID ='" & oDT.Rows(iRow)("WorkCenterID").ToString + "'"
If oDV.Count > 0 Then oChk.Checked = True

'Load all Functional Areas
oTR = New TableRow
oTD = New TableCell
oTB = New Table
oTB.ID = "tb_WorkCenter_" & oDT.Rows(iRow)("WorkCenterID").ToString.Replace("-", "")
oTB.Style.Add("display", IIf(oChk.Checked, "block", "none"))

LoadFunctionalArea(oTB, oDT.Rows(iRow)("WorkCenterID"))

oTD.Controls.Add(oTB)
oTR.Cells.Add(oTD)
tbWorkCenter.Rows.Add(oTR)

Next
End If