Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1060643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:21:29+00:00 2026-05-16T18:21:29+00:00

Currently, I’m using an AJAX Handler to populate the JSTree: $(function () { $(#jstree).jstree({

  • 0

Currently, I’m using an AJAX Handler to populate the 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); });

  });

The handler actually makes a database call, loops through the menu items, creates a JSON object that is serialized, sent back, and rendered:

 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

The idea here is to bind the move_node to a function that will hit the handler and update the database as to where I moved the object. I’ve been able to create the bind to do that. The problem, however, is that I can’t seem to obtain the ID. I’m setting it in the attributes in the population of the JSON object, but when I do a watch on the NODE and REF objects via console.log, the id field is empty.

What gives? Any ideas? Am I missing something vital?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:21:30+00:00Added an answer on May 16, 2026 at 6:21 pm

    After fiddling with it once again, I found the answer:

    cnode.attributes
    node.attributes
    

    It must be name specific underneath, these must be cnode.attr and node.attr to work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I am using a pretty basic function to pre-load images: function preload(arrayOfImages) {
Currently I am using HTML files for parts of my user interface. I display
currently, I`m implementing a map App with Mono4Droid and there I`m using a WebView
Currently i'm having trouble using two functions in my -(void)viewDidLoad , both of these
Currently I am using Amazon Cloudfront to service static objects on my ASP.Net MVC3
Currently I have in my code tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(addCompoundToLabel:)]; My code
Currently I have a web service, which loads up any plugins located within its
Currently I'm using the Jackson JSON Processor to write preference data and whatnot to
Currently writing a C# application it should do backups using GIT in the background.
Currently using a MySQL database Wanting to insert a new row into a table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.