• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Tree

Guest
Feb 10, 2007 Feb 10, 2007

Copy link to clipboard

Copied

Hello,

Does someone know a good way of saving the information from the tree component (names of nodes and their hierarchy) into a database? The same information will have to be pulled out of the database later in the application.

P.S.
I am trying to design an admin system for a menu on the website, which is very similar to the tree (the menu entries have sub entries).

Please share your thoughts and ideas.
TOPICS
Advanced techniques

Views

537

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 10, 2007 Feb 10, 2007

Copy link to clipboard

Copied

I made a quick function to do this take a look........

I have also posted a question on manually sorting a tree as well. This might be of use to you. Its not totally working but hopefully it will soon

Jeff

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 11, 2007 Feb 11, 2007

Copy link to clipboard

Copied

We of course have to first convert Jedale's code from Java to CFML.



Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 11, 2007 Feb 11, 2007

Copy link to clipboard

Copied

That is actually Actionscript not Java

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 11, 2007 Feb 11, 2007

Copy link to clipboard

Copied

That is actually Actionscript not Java
Oh, yes, var var not Java. Sorry, Simon, didn't look that far. I had something else in mind. I am translating it into Actionscript and CFML.






Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 11, 2007 Feb 11, 2007

Copy link to clipboard

Copied

I undestand the algorithm . . . However, the Coldfusion code would help a lot . . .

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 11, 2007 Feb 11, 2007

Copy link to clipboard

Copied

First off you have to have a flash form so in your <cfform> tag make sure you have a format="flash" somewhere.

The actionscript goes between cfformitem tags:
<cfformitem type="script">
...actionscript here...
</cfformitem>

and then you call the actionscript by:

<cfinput type="button" name="EOWSort" width="110" disabled="true" value="Save Sort Order" onClick="alert(makeTreeList(Programs));">

Where Programs is the name of my tree, you need to change this to the name you gave your own tree.

An alert will pop up in a flash form and tell you the order of the items.

Hopefully that helps

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 11, 2007 Feb 11, 2007

Copy link to clipboard

Copied

I think i solved the problem of building the tree from the database . . .

used the following code . . .

<cfquery name="Pull_Child" datasource="blahblah">
Select Category, ParentName
From menu
Where ParentLevel is not null
</cfquery>


<cfloop query="Pull_Child">
<cftreeitem value = "#Category#" parent = "#ParentName#" queryAsRoot = "Main Menu" expand = "no">
</cfloop>


the table contains (Category Name - Name of a node, Parent Name - name of the parent node, ParentLevel - level of the node in the tree)

Now I am facing another task - analyzing the database and outputting the correct html code for the menu . . . (if you have any suggestions on this, please post)

Thanks to all of you for help . . .

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 14, 2007 Feb 14, 2007

Copy link to clipboard

Copied

> I think i solved the problem of building the tree from the database . . .
I had thought all along you wished instead to build a database from a tree . That is, to save tree information into the database.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 14, 2007 Feb 14, 2007

Copy link to clipboard

Copied

Jedale, I have an applet that has some of your code. However, I am not too sure about getLength() as a function of a tree, and of the negative argument in treelist.slice(0, -1). What do you want the function makeTreeList to do?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 16, 2007 Feb 16, 2007

Copy link to clipboard

Copied

LATEST
I made the function to get all of the data values in the tree to make into a list. This list is then remoted to a cfc so that the order of the tree is preserved (I also have a sorting function that is not yet working completely and have posted a question at this forum). So once the user comes to my page the tree is populated via remoting in the correct sequence. That was my intention in using this code, but the hang up is on the tree sorting correctly.

I used the slice command to remove the last comma in the list. I know its not really needed but I like to keep things nice and neat. Additionally, the getlength() function just provides the number of items within a tree, combobox, grid. Sometimes a simple ".length" will work for certain components.

I'm sure you knew this but my example to get the actionscript to run with the onclick function should have an input argument of the name of your cftree. I will edit this.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation