Json to json Tree Structure
When writing a Restful service, because all returned objects are json objects, these objects are related, but they are not well reflected. when returning to the page, cannot be a tree. The returned json
able to set an additional requirement: All file names cannot exceed a certain number of characters.In addition, because my project is uploaded to Amazon S3, some folders will not be returned to me, such as this file "Root/ti/asdfasdfasdfasdfasdfasdfasdf.txt" does not return "root/ti/", so we have to add a hierarchical data.We'll walk through this tree object here, and simply deal with it.ConstTraverseTree= function(data){ return Data.Map(item)= {
Example: Create a tree: Local JSON
Create a Tree
No url is set.
ShowTreeIcon = "true" textField = "text" idField = "id">Set Data in Javascript
Var tree3 = mini. get ("tree3 ");Tree3.loadData ([{Id: "lists", text: "Lists", expanded: false,Children :[{Id: "datagrid", text: "DataGrid "},{Id: "tree", text: "
root.sortchildren (); A JSON string System.out.println (root) that outputs an ordered tree menu; The output of the program is as follows:////Unordered Tree menu (formatted results can be viewed using the JSON Format tool,//e.g. http://jsonviewer.stack.hu/online
Originally the project needs a tree structure, and then randomly chose a easyui tree open source Framework, and then encountered a problem, I want to recursively from the database structure, turn to JSON, how to do? Is it a recursive stitching StringBuilder? It would be foolish to do so. Then all kinds of Baidu, blog Park, QQ Group to ask, the answer is also a va
After reading the article "using Hibernate to realize the tree structure infinite level classification", I also want to post and share the complete demo (including source code) of the functional module tree that I use in all the projects I developed. In fact, in my blog has been posted, due to the time relationship did not properly tidy.
The functional module tree
Using ExtJS2, asynchronously reads the data in JSON (JavaScript Object notation) Treeloader constructs an asynchronous-loaded tree.
1. Download ExtJS2, Address: http://www.extjs.com/
Download ext JS 2.1 sdk:ext-2.1.zip.
The examples folder is full of ExtJS example demo program.
ExtJS2 main will use the following several files: Ext-all.css, Ext-base.js, Ext-all.js, the use of the method can refer to the demo
Reprinted: http://www.javaeye.com/topic/249851
Since learning to use jquery, I have never found a simple tree that supports asynchronous loading, but I have to extend it myself. The Treeview function of jquery's official UI is single and not small enough. The simpletree plug-in finds that it is small and supports drag-and-drop extension. Therefore, based on simpletree, The JSON format data is asynchronously
Recursive method to generate JSON tree data var getjsontree = function (data, parentid) { var itemarr = []; for (var i = 0; i JavaScript recursive method for generating JSON tree structure data
Recursive method to generate JSON tree data var getjsontree = function (data, parentid) { var itemarr = []; for (var i = 0; i JavaScript recursive method for generating JSON tree structure data
Recursive method to generate JSON tree data var getjsontree = function (data, parentid) { var itemarr = []; for (var i = 0; i JavaScript recursive method for generating JSON tree structure data
Recursive method to generate JSON tree data var getjsontree = function (data, parentid) { var itemarr = []; for (var i = 0; i JavaScript recursive method for generating JSON tree structure data
The program is mainly assembled in JSON-formatted tree data files, divided into two parts:
A simple pojo that represents a node
public class TreeNode {
Private long nodeId;Private String nodename;Private long Father_nodeid;Public TreeNode () {}Public TreeNode (Long nodeid,string nodename,long Father_nodeid) {This.nodeid=nodeid;This.nodename=nodename;This.father_nodeid=father_nodeid;}
Public long Getnodeid
Obtain the json string of the tree type.
Public class TreeNode {Private long nodeId;
Private String nodeName;
Private long fatherNodeId;
Public TreeNode (){
}
Public TreeNode (long nodeId, String nodeName, long fatherNodeId ){
This. nodeId = nodeId;
This. nodeName = nodeName;
This. fatherNodeId = fatherNodeId;
}
Public long getNodeId (){
Return nodeId;
}
Public void setNodeId (long nodeId ){
This. nodeId =
difference is
Because we're backing up the JSON string in the background, we need to convert the JSON string into a JSON array (the bootstrap jquery TreeView tree Control on the web only supports the JSON array), and it took a lot of effort to find it. Student
First, I will post a picture to show you how to implement a dynamic menu of Accordion layout, which is commonly known as the layout of a hand-held piano. window. window), select accordion for layout, code:
VaR win = ext. create ("Ext. window. window ", {Title:" accordion layout dynamic menu ", width: 300, height: 500, iconcls:" icon-accordion ", autoscroll: false, layout: 'accordion ', // set layoutconfig: {Animate: True // dynamically switch tree spa
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.