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 8753153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:22:25+00:00 2026-06-13T13:22:25+00:00

Currently, I have two Stored Procedures in SQL Server that handle retrieving a tree

  • 0

Currently, I have two Stored Procedures in SQL Server that handle retrieving a tree from the database:
The first retrieves all of the nodes at a specific level when you pass in a level number.
The other retrieves the children of a specific node when you pass in Level, Left, and Right values.

I’m using MVC 3.
Ideally, I would like to setup JSTree to make a call to the database every time a user clicks to expand a node. So instead of loading the entire tree up in a Json model on the server and then passing it to JSTree as is typical, I’d like to instead ONLY pass in the children for the specific node that is clicked by the user. This will happen at every node so that ONLY the children of the immediate node will have to be passed into the JSTree instead of the entire tree.

Is this possible? And if so, I would appreciate some example code for the view (especially) and possibly the controller using Microsoft’s MVC 3 framework. I’d appreciate any help.

  • 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-06-13T13:22:27+00:00Added an answer on June 13, 2026 at 1:22 pm

    Yes this is possible, it’s actually pretty straightforward with jstree.

    What you want to do is use the ajax parameter of the json_data jstree plugin, but set it up so that either the data or url parameter is passed a function that will send off which node id has been expanded so that your webservice can make the call to your stored procedure and return the data for the children of the selected node.

    Here’s one of the examples from http://www.jstree.com/documentation/json_data modified a bit:

    $("#tree").jstree({ 
      "json_data" : {
         "ajax" : {
           "url" : "/yourwebservice/getnodechildren",
           "data" : function (node) { 
               //this is passed the node being opened
               //or -1 if it's the root node
    
               var dataToPass = {};
    
               if (node === -1) {
                  //pass parameters to the webservice that will build and return
                  //first two tree levels
    
                  dataToPass = { 
                    id : 0,
                    initialLoad: true
                  }; 
               }
    
               if (node.attr && node.attr("id") {
                   dataToPass = {
                     id: node.attr("id"),
                     initialLoad: false
                   }
               }
    
               return dataToPass;
    
            },
            "success" : function (dataFromWebservice) {
                //depending on how the webservice returns
                //data you may need to do this
                return dataFromWebservice.d;
            }
          }
        },
    "plugins" : [ "themes", "json_data" ]
    });
    

    You can make this code quite a bit more elegant but that’s the gist. This will allow you to build out the tree on demand in chunks rather than all at once.

    If your webservice is set up so that parameters are passed on the url, just make the url the function instead and use that to build up your url request with the id of the node instead or whatever other parameters you need.

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

Sidebar

Related Questions

I currently have two SQL commands. One retrieves a list of unique IDs from
I have two stored procedures that return a slightly different set of columns. I
I have two stored procedures that I want execute wrapped in a transaction. For
I (currently) have two forms, one that needs to call the other. In other
Currently I have two tests that each individually test for a button_click within a
I have a SQL Server table full of orders that my program needs to
I have an application on a SQL Server 2008 database. This database has a
I have two simple stored procedures in SqlServer: SetData(@id int, @data varchar(10)) GetData(@id int)
I have a database that has two tables. These two tables are defined as:
In SQL Server, I have two fields, one is primary and has an identity

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.