Drag and Drop Tree Control
Drag and Drop the nodes in the treeview below. Right-click for a context menu with more options.
This treeview is a simple unordered HTML list wich is totally styled with CSS.
Output
By setting the attribute type="advanced" and using the provided javascript file, DBTree will create a fully customizable
collapsible tree with drag & drop functionality as well as a right-click contextmenu.
Other than for the simple treeview, you have to write less code on the editpage.
The following pages have to be created:
- 1. Page for a treeview
- 2. Page for switching the action: editpage
- 3. Page for inserting a new record
- 4. Page for updating a record
1. Page for a treeview
The first page we create contains the treeview of our database table. Note the attributes action="edit" and type="simple". With the editpage attribute you indicate the path to the second page.
Instead of using datasource and table, you could also retrieve the records from cfquery and then use the query attribute.
Drag and Drop the nodes in the tree below. Right-Click on a element for more
options. The Database is automatically updated with DBTree using Ajax.
Syntax
<cfmodule template="relative path to dbtree.cfm" instancename="treeview" action="edit" type="advanced" datasource="name of the datasource" table="name of the database table" id="column name" parent="column name" contentfield="column name" editpage="web/demo/edittree2.cfm" btn_addroot="create new root" btn_moveroot="move to root" btn_add="add node" btn_edit="edit node" btn_delete="delete node" btn_up="move upwards" btn_down="move downwards" item="images/bullet.gif" folderopen="images/minus.gif" folderclosed="images/plus.gif" imagewidth="20px" imageheight="20px" fontsize="13px" color="000" contextlinkcolor="000" contextlinkcolor_over="fff" contextbgcolor="eee" contextbgcolor_over="6ea4f4" tipcolor="fff" tipbgcolor="6ea4f4">
[ Up ]
2. Page for switching the action: editpage
The "editpage" receives the url parameters node and action. Now you
have to switch the actions with a cfswitch or an if-then-else construct
to forward the user to an appropriate form for inserting or updating
the database record with the given node-id.
Here is an example for a edit page:
Example Code
[ Up ]
3. Page for inserting a new record
This is the form action page for inserting a record into a DBTree table. Note: the new record will become the last child of node="".
Syntax
<cf_dbtree instancename="id of the menu" datasource="name of the datasource" table="name of the database table" action="insert" id="column name" parent="column name" node="#form.id#" formfields="title,link,target"> <cflocation url="advanced-edit-mode.cfm" addtoken="no">
[ Up ]
4. Page for updating a record
This is the form action page for updating a record in a DBTree table. Note: the node attribute is the record id.
Syntax
<cf_dbtree instancename="id of the menu" datasource="name of the datasource" table="name of the database table" action="update" id="column name" parent="column name" node="#form.id#" formfields="title,link,target"> <cflocation url="advanced-edit-mode.cfm" addtoken="no">
[ Up ]
Search
Brandnew!
DBTree Configurator!
A great wizard for getting started with DBTree. UI to generate the tags' attributes: DBTree Configurator!
Add Comment
