Skip to main content
January 19, 2011
Question

Array of Structs in cftree

  • January 19, 2011
  • 1 reply
  • 1432 views

Hi,

I am using an array of structs to populate the data in a cftree and cfloop query to fill the structs, this worked well initially, but as the data is increasing, it gets slower and slower, is there a solution for this ?

<cfcomponent name="treeComp">

<cffunction name=mytree>

<cfargument name="path" required="Yes">

<cfargument name="value" required="Yes">

     <cfset result = arrayNew(1)>

     <cfquery datasource="source" name="entries">

          SELECT value, name FROM data

     </cfquery>

     <cfloop query="entries">

               <cfset item=StructNew()>

               <cfset item.value=entries.value>

               <cfset item.display=entries.name>

               <cfset arrayappend(result,item)>

     </cfloop>

     <cfreturn result>

</cffunction>

</cfcomponent>

tree.cfm

-----------

<cfform>

<cftree name="tree" format="html">

     <cftreeitem bind="cfc:treeComp.mytree({cftreeItemPath},{cftreeItemValue})">

</cftree>

</cfform>

    This topic has been closed for replies.

    1 reply

    Inspiring
    January 20, 2011

    I am not really familiar with cftree, so I looked at the docs.  The example simply loops through a query.  Converting a query to an array of structs might be unnecessary processing.

    January 20, 2011

    Hi Dan,

    thank you for the suggestion, but in this case, I have the value and the display fields that need to be stored, if I just loop over a query, I do not get the desired results. can you point me to the example you have seen ?

    Thanks

    Inspiring
    January 21, 2011

    regarding:

    can you point me to the example you have seen ?

    google "cftree"

    select any adobe offering.