Need help with some client side javascript.

2 posts, 0 answers
  1. Pat Huesers
    Pat Huesers avatar
    20 posts
    Member since:
    Jan 2008

    Posted 29 Sep 2009 Link to this post

    I have a treeview (Q3 2008) control that I am bulding the nodes for programmatically.   The node I am working with has 15 controls in it. I am trying to execute some js to access the controls in this node so I can change the text and other things.  Here is what I have tried.  Please excuse the fact that I am lost!

    Here is the code that builds the Node.

    This is the calling code from the populatenodeondemand sub

    Dim node As New RadTreeNode()
    node.Controls.Add(FormatNode(row))

    Here is the function that makes the node.

    Function FormatNode(ByVal rowData As DataRow) As Table

    Dim tblReturn As New Table
    Dim rowReturn As New TableRow

    Dim cellCallOut As New TableCell
    Dim cellDescription As New TableCell
    Dim cellQuad As New TableCell
    Dim cellLabor As New TableCell
    Dim cellPartNumber As New TableCell
    Dim cellPrice As New TableCell
    Dim cellInStock As New TableCell
    Dim cellAddandRemove As New TableCell
    Dim cellInventoryCount As New TableCell

    Dim intDescriptionCellIndentSpacing As Integer = 10
    Dim intDescriptionCellWidth As Integer = 180

    rowReturn.VerticalAlign = VerticalAlign.Top

    cellDescription.VerticalAlign = VerticalAlign.Top

    cellDescription.HorizontalAlign = HorizontalAlign.Left
    cellCallOut.ForeColor = Drawing.Color.Crimson

    cellInventoryCount.ForeColor = Drawing.Color.Blue

    With rowData
    If Not IsDBNull(.Item("Callout")) Then
    cellCallOut.Text = .Item("Callout").ToString
    Else
    cellCallOut.Text = ""
    End If

    Dim intIndent As Integer
    Try
    If Not IsDBNull(.Item("IndentCode")) Then
    intIndent = CInt(.Item("IndentCode"))
    End If
    Catch ex As Exception
    intIndent = 0
    End Try

    If Not IsDBNull(.Item("IndentCode")) Then
    cellDescription.Text += .Item("Description").ToString
    cellDescription.Style.Add("padding-left", (intIndent * intDescriptionCellIndentSpacing).ToString + "px")
    cellDescription.Attributes.Add("width", (intDescriptionCellWidth - (intIndent * intDescriptionCellIndentSpacing)).ToString + "px")
    Else
    cellDescription.Text = " "
    cellDescription.Attributes.Add("width", intDescriptionCellWidth.ToString + "px")
    End If

    If Not IsDBNull(.Item("QuadRight1")) Then
    cellQuad.Text += .Item("QuadRight1").ToString
    End If

    If Not IsDBNull(.Item("QuadRight2")) Then
    cellQuad.Text += .Item("QuadRight2").ToString
    End If

    If Not IsDBNull(.Item("LaborHours")) Then
    cellLabor.Text = .Item("LaborHours").ToString
    End If

    If Not IsDBNull(.Item("PartNumber")) Then
    cellPartNumber.Text = .Item("PartNumber").ToString

    Dim imgAddIcon As New ImageButton
    imgAddIcon.ImageUrl = "Img/AddIcon.png"
    imgAddIcon.OnClientClick = "addPart('" + .Item("PartNumber").ToString + "');return false;"
    cellAddandRemove.Controls.Add(imgAddIcon)

    Dim imgRemoveIcon As New ImageButton
    imgRemoveIcon.ImageUrl = "Img/RemoveIcon.png"
    imgRemoveIcon.OnClientClick = "removePart('" + .Item("PartNumber").ToString + "');return false;"
    cellAddandRemove.Controls.Add(imgRemoveIcon)
    End If

    If Not IsDBNull(.Item("InvCount")) Then
    If .Item("InvCount") > 0 Then
    cellInStock.ToolTip = .Item("InvCount").ToString + " In Stock"
    Dim imgInStock As New ImageButton
    imgInStock.ImageUrl = "Img/InStock.png"
    imgInStock.OnClientClick = "showInventory('" + .Item("PartNumber").ToString + "');return false;"
    cellInStock.Controls.Add(imgInStock)
    End If
    End If

    If Not IsDBNull(.Item("StockNumberInvCount")) Then
    If .Item("InvCount") > 0 Then
    cellInventoryCount.Text = .Item("StockNumberInvCount").ToString
    End If
    End If


    If Not IsDBNull(.Item("Price")) Then
    cellPrice.Text += Format(.Item("Price"), "C")
    Else
    cellPrice.Text += ""
    End If

    End With

    cellAddandRemove.CssClass = "cellAddandRemove"
    cellInventoryCount.CssClass = "cellInventoryCount"
    cellCallOut.CssClass = "cellCallOut"
    cellQuad.CssClass = "cellQuad"
    cellLabor.CssClass = "cellLabor"
    cellPartNumber.CssClass = "cellPartNumber"
    cellPrice.CssClass = "cellPrice"
    cellInStock.CssClass = "cellInStock"

    rowReturn.Cells.Add(cellAddandRemove)
    rowReturn.Cells.Add(cellInventoryCount)
    rowReturn.Cells.Add(cellCallOut)
    rowReturn.Cells.Add(cellDescription)
    rowReturn.Cells.Add(cellQuad)
    rowReturn.Cells.Add(cellLabor)
    rowReturn.Cells.Add(cellPartNumber)
    rowReturn.Cells.Add(cellPrice)
    rowReturn.Cells.Add(cellInStock)

    tblReturn.Rows.Add(rowReturn)


    Return tblReturn
    End Function

    And here is the js.  I really have just been trying to get to the controls.  So please show me how to find to control and then to modify it.  Specifically the text in a cell.  The var currNode is set to the current node by the Mouseovernode event.

     function addPart(partnumber) {
    var tree = $find("<%= tvSection.ClientID %>");
    var pn;
    if (currNode != null) {
    var nodeControls = currNode.get_textElement();
    var tbQuantity = nodeControls[2];
    var tbQuantity2 = currNode.findControl("cellInventoryCount");
    var nodeAttrib= currNode.get_attributes();
    }

    }

     

  2. Pat Huesers
    Pat Huesers avatar
    20 posts
    Member since:
    Jan 2008

    Posted 30 Sep 2009 Link to this post

    I figured it out.   I added a label control and set its ID, now findControls works perfect!
Back to Top