E43509
asked on
Using CFTREE to show recursive relationships
I'm struggling to expose a hierarchical query as a tree view in ColdFusion. I just can't figure out the mechanics.
Initially I want to expose it without a bind to a cfc. Then I want to expose it with a bind to a cfc so I can take advantage of the complete tree not loading until it is clicked.
Here is what the first level needs to be exposed as:
When you open all the levels:
Here a sample table which ties the parent and children together.
My attempt which didn't yield what I expected
My output looks like this as it doesn't walk up tree
Initially I want to expose it without a bind to a cfc. Then I want to expose it with a bind to a cfc so I can take advantage of the complete tree not loading until it is clicked.
Here is what the first level needs to be exposed as:
When you open all the levels:
Here a sample table which ties the parent and children together.
CREATE TABLE mycurric
(parent_cd_crs VARCHAR2(30 BYTE),
child_cd_crs VARCHAR2(30 BYTE))
/
INSERT INTO mycurric (CURRIC_CD_CRS,CHILD_CD_CRS)
VALUES('MASTERCU','CRSA');
INSERT INTO mycurric (CURRIC_CD_CRS,CHILD_CD_CRS)
VALUES('MASTERCU','LEVEL1ACU');
INSERT INTO mycurric (CURRIC_CD_CRS,CHILD_CD_CRS)
VALUES('MASTERCU','LEVEL1BCU');
INSERT INTO mycurric (CURRIC_CD_CRS,CHILD_CD_CRS)
VALUES('MASTERCU','LEVEL1CCU');
INSERT INTO mycurric (CURRIC_CD_CRS,CHILD_CD_CRS)
VALUES('LEVEL1ACU','CRSB');
INSERT INTO mycurric (CURRIC_CD_CRS,CHILD_CD_CRS)
VALUES('LEVEL1ACU','CRSC');
INSERT INTO mycurric (CURRIC_CD_CRS,CHILD_CD_CRS)
VALUES('LEVEL1ACU','CRSD');
INSERT INTO mycurric (CURRIC_CD_CRS,CHILD_CD_CRS)
VALUES('LEVEL1ACU','CRSE');
INSERT INTO mycurric (CURRIC_CD_CRS,CHILD_CD_CRS)
VALUES('LEVEL1BCU','LEVEL2ACU');
INSERT INTO mycurric (CURRIC_CD_CRS,CHILD_CD_CRS)
VALUES('LEVEL1BCU','LEVEL2BCU');
INSERT INTO mycurric (CURRIC_CD_CRS,CHILD_CD_CRS)
VALUES('LEVEL1BCU','LEVEL2CCU');
INSERT INTO mycurric (CURRIC_CD_CRS,CHILD_CD_CRS)
VALUES('LEVEL1CCU','CRSC');
INSERT INTO mycurric (CURRIC_CD_CRS,CHILD_CD_CRS)
VALUES('LEVEL1CCU','CRSG');
INSERT INTO mycurric (CURRIC_CD_CRS,CHILD_CD_CRS)
VALUES('LEVEL2ACU','CRSA');
INSERT INTO mycurric (CURRIC_CD_CRS,CHILD_CD_CRS)
VALUES('LEVEL2ACU','CRSF');
INSERT INTO mycurric (CURRIC_CD_CRS,CHILD_CD_CRS)
VALUES('LEVEL2BCU','CRSG');
INSERT INTO mycurric (CURRIC_CD_CRS,CHILD_CD_CRS)
VALUES('LEVEL2CCU','LEVEL3ACU');
INSERT INTO mycurric (CURRIC_CD_CRS,CHILD_CD_CRS)
VALUES('LEVEL3ACU','CRSD');
My attempt which didn't yield what I expected
<html>
<title> my curric TreeExample</Title>
<body>
<cfform name="myform">
<cfquery name="GetList" datasource="myConn" username="myuser" password="mypad">
SELECT parent_cd_crs, child_cd_crs from mycurric</cfquery>
<cftree name="treeTest" height="400" width="200" format="html">
<cftreeitem
query="GetList"
value="parent_cd_crs,child_cd_crs"
parent="parent_cd_crs"
display="parent_cd_crs, child_cd_crs"
queryasroot="NO" expand="no">
</cftree>
<hr>
</cfform>
</body>
</html>
My output looks like this as it doesn't walk up tree
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
yes, certainly a CSS?javascript/Jquery Solution would be much better, if you still wanna use cftree, i suggest you to look into the custom tag cfx_tree which is free and quite advantageous ranther than cftree.
or you can create a custom tag to make recursive calls. but that may slow down the things
or you can create a custom tag to make recursive calls. but that may slow down the things
ASKER
Thanks.
I could not find cfx_tree in my searches ... do you have a url?
I found a cf_dbtree ($)
I could not find cfx_tree in my searches ... do you have a url?
I found a cf_dbtree ($)
ASKER
Excellent and robust response.
ASKER
I've been beating myself up trying to noodle out how this tag worked and not getting anything good out of it.
Appreciate your timely response.
I was wondering if I should stay away from the cftree tag and devote my efforts toward a javascript/css solution instead? I could not find a lot of info when I google'd CFTREE.
Which way would you lean?
Thanks again.