4

Have a question on recursively populating JsTree using the .NET wrapper available via NuGet. Any help would be greatly appreciated.

the .NET class JsTree3Node has a property named Children which holds a list of JsTree3Nodes, and the pre-existing table which contains the node structure looks like this

NodeId    ParentNodeId     Data            AbsolutePath 
1         NULL             News            /News 
2         1                Financial       /News/Financial 
3         2                StockMarket     /News/Financial/StockMarket

I have a EF data context from the the database, so my code currently looks like this.

var parentNode = new JsTree3Node(Guid.NewGuid().ToString());

foreach(var nodeItem in context.Nodes)
{
   parentNode.Children.Add(nodeItem.Data);
   // What is the most efficient logic to do this recursively?
}

as the inline comment says in the above code, what would be the most efficient way to load the JStree data on to the parentNode object.

I can change the existing node table to suite the logic so feel free to suggest any changes to improve performance.

  • 1
    Is performance actually a problem right now? – Robert Harvey Jun 6 '14 at 1:05
  • @RobertHarvey It is not. but i am interested in finding out the "right" way to do it with the least use of CPU cycles. and to be honest i cannot think of a proper logic at all for the moment. any help would be appreciated. – Ahsan Jun 6 '14 at 1:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.