There are many web based tree controls, such as dthmlxtree(published by Saint-Petersburg, Russia), xtree(published by WebFX) and Microsoft DeepTree used in msdn. These controls let web based applications as convenience as C/S applications. But these controls have limitations such as coding is complicate, hard to modify and so on. This article will introduce how to build a web based tree control step by step using xml&xslt, and how the key features works.
1. web based using xml&xslt.
2. light weight, all codes less than 13k(images excluded).
3. xp explorer style operations, support keyboard navigation.
4. support IE, firefox, not tested on opera and other browsers.
5. simple data file, conveniently generated from database.
Features to be implemented
1. edit node title in place.
2. drag&drop or cut&paste (within one tree, between trees).
3. Dynamic Loading for big trees.
4. check boxes.
Using the code
Build xml data file as following structure:
In this xml file, href="/KB/HTML/xtree/xsl" directive lead xml processor to format xml by using xtree.xsl. Be aware directory imgs is required.
HTML from above display a node status mark(plus or minus), a node icon and node tile, and connect event processor. This is a single node prototype. If this node have a child, codes as following is inserted:
<div class=" tree-node "> is a big area to hold nodes own content and all of its children, <div class=" sub-container"> is a smaller area to hold all children, <div class=" sub- padding "> is another smaller area to hold all children which are indented from their parent.