Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ASP.net/jQuery:JSTree,选择节点,can';我好像拿不到身份证_Asp.net_Jquery_Vb.net_Jstree - Fatal编程技术网

ASP.net/jQuery:JSTree,选择节点,can';我好像拿不到身份证

ASP.net/jQuery:JSTree,选择节点,can';我好像拿不到身份证,asp.net,jquery,vb.net,jstree,Asp.net,Jquery,Vb.net,Jstree,目前,我正在使用AJAX处理程序填充JSTree: $(function () { $("#jstree").jstree({ "json_data": { "ajax": { "url": "AJAXHandler.aspx?action=GetMenu" } }, "plugins": ["themes

目前,我正在使用AJAX处理程序填充JSTree:

$(function () {
        $("#jstree").jstree({
            "json_data": {
                "ajax": {
                    "url": "AJAXHandler.aspx?action=GetMenu"
                }
            },
            "plugins": ["themes", "json_data", "dnd"]
        })
        .bind("move_node.jstree", function (node, ref, position, is_copy, is_prepared, skip_check) {
            console.log(node); });

  });
处理程序实际上进行数据库调用,循环菜单项,创建一个JSON对象,该对象被序列化、发回并呈现:

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Select Case Request("action")
            Case "GetMenu"
                GetMasterMenu()
            Case "UpdateMenuHiearchy"
                UpdateMenuHiearchy()
        End Select
    End Sub

    Private Sub GetMasterMenu()
        Dim dt As DataTable = GetMenu()
        Dim nodesList As New List(Of JsTreeNode)()
        PopulateNodes(dt, nodesList)
        Dim ser As New JavaScriptSerializer()
        Dim res As String = ser.Serialize(nodesList)
        Response.ContentType = "application/json"
        Response.Write(res)
        Response.[End]()
    End Sub

    Private Sub PopulateNodes(ByRef dt As DataTable, ByVal nodes As List(Of JsTreeNode))

        Dim parents() As DataRow = dt.Select("PARENT_MENU_ID = 0")

        'Root Nodes
        For Each dr As DataRow In parents
            Dim node As New JsTreeNode()
            node.attributes = New Attributes()
            node.attributes.id = dr("APPLICATION_MENU_ID").ToString
            node.attributes.rel = "root" & dr("APPLICATION_MENU_ID").ToString
            node.data = New Data()
            node.data.title = dr("DESCRIPTION")
            node.state = "open"

            'Check for Children
            Dim strSQL As New StringBuilder
            With strSQL
                .Append(" SELECT * FROM APPLICATION_MENU WHERE PARENT_MENU_ID = " & dr("APPLICATION_MENU_ID") & "")
            End With

            Dim dtChildren As DataTable = DatabaseManager.Query(strSQL.ToString)
            If dtChildren.Rows.Count > 0 And dtChildren IsNot Nothing Then
                For Each drChild As DataRow In dtChildren.Rows
                    AddChildNodes(dt, dr("APPLICATION_MENU_ID"), node)
                Next
            End If
            node.attributes.mdata = "{draggable : true}"
            nodes.Add(node)
        Next
    End Sub

    Private Sub AddChildNodes(ByRef dt As DataTable, ByVal parentID As Integer, ByVal node As JsTreeNode)
        Dim strSQL As New StringBuilder
        With strSQL
            .Append(" SELECT * FROM APPLICATION_MENU WHERE PARENT_MENU_ID = " & parentID.ToString & "")
        End With
        Dim dtChildren As DataTable = DatabaseManager.Query(strSQL.ToString)
        node.children = New List(Of JsTreeNode)()

        For Each drChild As DataRow In dtChildren.Rows
            Dim cnode As New JsTreeNode()
            cnode.attributes = New Attributes()
            cnode.attributes.id = drChild("APPLICATION_MENU_ID").ToString
            node.attributes.rel = "folder"
            cnode.data = New Data()
            cnode.data.title = drChild("DESCRIPTION")
            cnode.attributes.mdata = "{draggable : true }"

            strSQL = New StringBuilder
            With strSQL
                .Append(" SELECT * FROM APPLICATION_MENU WHERE PARENT_MENU_ID = " & drChild("APPLICATION_MENU_ID") & "")
            End With

            Dim dtChildren2 As DataTable = DatabaseManager.Query(strSQL.ToString)
            If dtChildren.Rows.Count > 0 And dtChildren IsNot Nothing Then
                AddChildNodes(dt, drChild("APPLICATION_MENU_ID"), cnode)
            End If
            node.children.Add(cnode)
        Next
    End Sub
这里的想法是将move_节点绑定到一个函数,该函数将命中处理程序并更新数据库,以确定我将对象移动到了哪里。我已经能够创建绑定来实现这一点。然而,问题是我似乎无法获取ID。我在JSON对象填充的属性中设置了ID,但是当我通过console.log监视节点和REF对象时,ID字段是空的


有什么好处?有什么想法吗?我是否错过了一些重要的东西?

再次摆弄之后,我找到了答案:

cnode.attributes
node.attributes

下面必须是特定于名称的,必须是cnode.attr和node.attr才能工作。

再次摆弄它之后,我找到了答案:

cnode.attributes
node.attributes

下面必须是特定于名称的,必须是cnode.attr和node.attr才能工作。

您确实正确-

JStreeV1+使用jquery绑定等。。因此,您需要使用attr来获取对象属性(另请注意,IE7)对节点数据区分大小写,例如:


$(“#节点”).attr(“id”)=$(#node”).attr(“ID”)

你确实是对的-

JStreeV1+使用jquery绑定等。。因此,您需要使用attr来获取对象属性(另请注意,IE7)对节点数据区分大小写,例如:

$(“#节点”).attr(“id”)=$(#node”).attr(“ID”)