Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate a dynamic treeview with json data - dynatree in jsp
    primarykey
    data
    text
    <p>I have a table in database like this:</p> <pre><code>id - title - parentID ----------------------------- 1 Root null 2 item 1 1 3 item 2 1 4 item 3 1 5 item 3.1 4 </code></pre> <p>this should create something like this:</p> <pre><code>--Root ----item 1 ----item 2 ----item 3 -------item 3.1 </code></pre> <p>here's my controller to fetch the root node and its children:</p> <pre><code>@RequestMapping(value="/CourtBranch/LoadTreeView", method = RequestMethod.GET) public void LoadList(@RequestParam("ParentId") String parentID,HttpServletRequest req, HttpServletResponse resp) { List lst; if (parentID.equals("Root")) { lst = _COURTBRANCH.LoadTreeChildren(null, "Root"); // selects records which have parent=null } else { lst = _COURTBRANCH.LoadTreeChildren(parentID, "TreeNode"); // selects records which have parent=parentID } resp.setContentType("application/json"); resp.setCharacterEncoding("utf-8"); try { resp.getWriter().print(_gson.toJson(lst)); } catch (IOException e) { e.printStackTrace(); } } </code></pre> <p>and this script loads my root:</p> <pre><code>&lt;script type="text/javascript"&gt; $(function(){ $("#tree").dynatree({ initAjax: { url: "/CourtBranch/LoadTreeView.json?ParentId=Root", data: { mode: "funnyMode" } }, onActivate: function(node) { $("#echoActive").text(node.data.title); }, onDeactivate: function(node) { $("#echoActive").text("-"); } }); }); &lt;/script&gt; </code></pre> <p>now I need to know how to send the root's id to my controller to fetch root's children and add them to the root node. should I use appendAjax function? how?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload