// you're reading...

ColdFusion

Nesting Groups in ColdFusion

I ran into something interesting today that I had not attempted before regarding the group by attribute in a cfoutput statement.  I needed to separate content into different group headings, down to a fourth level.  On a whim I decided to group them in cfoutput tags with the appropriate group by attribute and was pleasntly surprised that I worked like a champ.  Below is a quick example of what I am talking about.  Do remember your query must be sorted correctly (basically the order you need your groupings in).


#variables.qryData.group1#


#variables.qryData.group2#


#variables.qryData.group3#


#variables.qryData.column#



Discussion

4 Responses to “Nesting Groups in ColdFusion”

  1. Hi,
    there’s a slight mistake in your sample code. The inner cfoutput tags must not have a query attribute.
    <cfoutput query=”variables.qryData” group=”group1″>
       #variables.qryData.group1#<br/>
       <cfoutput group=”group2″>
          #variables.qryData.group2#<br/>
          <cfoutput group=”group3″>
             #variables.qryData.group3#<br/>

    Cheers
    Chris

    Posted by Christoph Schmitz | February 18, 2009, 10:37 AM
  2. Hi,
    there’s a slight mistake in your sample code. The inner cfoutput tags must not have a query attribute.
    <cfoutput query=”variables.qryData” group=”group1″>
       #variables.qryData.group1#<br/>
       <cfoutput group=”group2″>
          #variables.qryData.group2#<br/>
          <cfoutput group=”group3″>
             #variables.qryData.group3#<br/>

    Cheers
    Chris

    Posted by Christoph Schmitz | February 18, 2009, 5:37 AM
  3. Chris, you are correct. This is what I like to call copy and paste haste! Thanks for pointing it out.
    Mike

    Posted by Mike Fleming | February 18, 2009, 11:14 AM
  4. Chris, you are correct. This is what I like to call copy and paste haste! Thanks for pointing it out.
    Mike

    Posted by Mike Fleming | February 18, 2009, 6:14 AM

Post a comment

Categories