Skip to main content
October 1, 2010
Question

Need suggestion to achieve this functionality

  • October 1, 2010
  • 2 replies
  • 858 views

Hi,

I was looking at cfgrid and cftree functionality. Is it possible to incorporate cftree within cfgrid. if I can create a tree like structure in cfgrid. I am looking for something like below: The hyphens would be replaced by checkboxes...

- Folders

   - subdfolder1

      - subsubfolder1

      - subsubfolder2

  - subfolder2

     - subsubfolder1

     - subsubfolder2

- Folder2

  - etc...

I am looking for something rich looking solution. It would be great if you can give some suggestion on these

    This topic has been closed for replies.

    2 replies

    BKBK
    Community Expert
    Community Expert
    October 2, 2010

    Grid and Tree are alternative ways of representing data in two dimensions. One is a table, the other, well, a tree.

    The addition of checkboxes is also superfluous, because a cfgrid or cftree enables you to make a selection.  However, there's nothing stopping you from putting 2 or more trees in a form.

    Here is an example I borrowed from the Adobe Livedocs on cftree . The cfdocexamples datasource is pre-installed in Coldfusion, so you can run it directly.


    <cfquery name="getCourses" datasource="cfdocexamples">
        SELECT d.dept_name, c.course_id, c.CorName, c.CorLevel, c.corName ||' ( ' ||c.corLevel ||' )' AS corLabel
        FROM CourseList c, Departments d
        WHERE d.Dept_ID = c.Dept_ID
        ORDER BY d.dept_Name, c.corName, c.corLevel
    </cfquery>

    <cfform name="studentForm" format="flash" width="400" height="450">
        <cfformgroup type="vertical">   
        <cftree name="courseTree1">
            <cfinput type="checkbox" name="chkbx1">
            <cftreeitem 
                query="getCourses" 
                value="dept_name,Course_id" 
                display="dept_name,CorLabel" queryasroot="NO" expand="yes,no">
        </cftree>
        <cftree name="courseTree2">
            <cfinput type="checkbox" name="chkbx2">
            <cftreeitem 
                query="getCourses" 
                value="dept_name,course_id" 
                display="dept_name,corName" queryasroot="NO" expand="yes,no">
        </cftree>    
        </cfformgroup>
    </cfform>

    Inspiring
    October 2, 2010

    I think you're probably pushing beyond the boundaries of what <cfgrid> and <cftree> can do.

    From your example you're demonstrating the tree requirement, but you don't explain how this ties into a grid.

    For the tree part, you might wanna look @ this: http://www.jstree.com/

    I've never used it - I just googled it up - but it might be worth looking at.

    --

    Adam