the singularity of being and nothingness
Grouping in CFLoop…Finally!
With the public release of ColdFusion 10 Beta yesterday, I thought I’d play around a bit with some of the new capabilities. One of the features added in this release is the ability to group in query loops using <cfloop>.
As expected, this is pretty straightforward, and has the same capabilities as the <cfoutput> corollary. Here’s a quick example:
<cfquery name="qproducts" datasource="somedatasource">
select *
from products
order by category,subcategory,product
</cfquery>
<cfoutput>
<cfloop query="qproducts" group="category">
<h1>#category#</h1>
<cfloop group="subcategory" groupcasesensitive="true" >
<h2>#subcategory#</h2>
<cfloop>
#product#<br />
</cfloop>
</cfloop>
</cfloop>
</cfoutput>
Pretty simple, but something which I know a lot of people have wanted for quite a while. Well, now you have it!
| Print article | This entry was posted by existdissolve on February 18, 2012 at 6:06 pm, and is filed under ColdFusion, Cool Stuff. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
