封装一个树形菜单二——JS渲染树
Part1:Get a tree widget
Here are many useful tree widgets :http://www.ajaxline.com/best-javascript-tree-widgets
?
I chose the one which is easiest to use ---- dtree, through which I can create a powful tree by just importing the given dtree.js file.
?
Here is the official website of dtree and you can find api and examples:
http://destroydrop.com/javascripts/tree/
?
?添加一个节点,可以指定该节点跳转的URL,例子中没有写点击后,怎么执行一个js事件,补充一下:
?
?
First,write an asp page to allow the tree to be showed when certain button is clicked.
?Second, the cs file to fulfill the AddBtn_Click event, which would fetch the data from the web server and draw the proper tree with the help of dtree js.
?
?
?
OK~ the function is ...potboiled . Because there are many flaws and hard to be used. Next time I will make it widget and the path of the XML will not be hard coded any more. Also allow users to decide the words to math the key of name , url and so on. In conclusion , I will try to make the hard codes not be hard in the next version.
?
