Simple Edit Mode

Output

For fully using DBTrees' modifying functionality, you need to create some .cfm pages. One page would contain the tree itself configurated for editing. On that page you would also have to indicate a page where you send the action and the node of that tree. This is made with the attribute editpage. The following pages have to be created:

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.

Syntax

<cf_dbtree
instancename="id of the menu"
datasource="name of the datasource"
table="name of the database table"
action="edit"
type="simple"
id="column name"
parent="column name"
contentfield="column name"
editpage="path to the edit page"
btn_addroot="create new root"
btn_moveroot="[move to root]"
btn_add="[add]"
btn_edit="[edit]"
btn_delete="[delete]"
btn_up="[up]"
btn_down="[down]">

[ 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="simple-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="simple-edit-mode.cfm" addtoken="no">

[ Up ]