473,382 Members | 1,657 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Grouping & Sorting in Coldfusion

139 100+
Hi there,

I'm replicating the look of an Access form in Coldfusion

In Access I can create group headers to sort my data, so all the jobs under a particular site appear under that site name - which appears only once.

I'm using a cfloop query to get all my results in CF so my site name is repeated constantly. - like so

Site: MYSITE1
Job1

Site:MYSITE1
Job2


How do I get it to appear only once, as a header for all the jobs underneath it? Obviously the loop will need to go on and output the jobs under the next site, with that only having one header as well. like so...

Site: MYSITE1
Job1
Job2
Job3

Site: MYSITE2
Job1
Job2

Thanks for your help!
Nov 17 '08 #1

✓ answered by jKara

You can also use cfoutput's group attribute. Just order your results by "Site" first. Then use nested cfoutput tags and group by "Site" as well.

Expand|Select|Wrap|Line Numbers
  1. <cfquery ..>
  2.        SELECT  Site, Job,  ... other columns
  3.        FROM     Thetable
  4.        ORDER BY Site, Job, ... other columns
  5. </cfquery>
  6.  
  7. <cfoutput query="yourQuery" group="Site">
  8.           #Site#<br>
  9.           <cfoutput>
  10.                #Job#<br>
  11.           </cfoutput>
  12. </cfoutput>
  13.  

6 4326
acoder
16,027 Expert Mod 8TB
Can you post the cfloop code.
Nov 17 '08 #2
ndeeley
139 100+
Hi Acoder,

I certainly can:

Expand|Select|Wrap|Line Numbers
  1. <tr>
  2.             <cfloop query="ManagerJobsIn">
  3.             <cfoutput>
  4.             <tr>
  5.             <td colspan="14" style="color: red; font-weight: 600;">#ClientFK#</td>
  6.             </td>    
  7.  
  8.             <tr>
  9.             <td colspan="14" style="color: red; font-weight: 600;">#SiteFK#</td>
  10.             </td>    
  11.  
  12.             <tr bgcolor="###iif(currentrow MOD 2,DE('ffffff'),DE('efefef'))#">
  13.             <td width="20%">#AssetClassFK#</td>
  14.             <td>#ManufacturerFK#</td>
  15.             <td>#ModelFK#</td>
  16.             <td>#PowerRating#</td>
  17.             <td>#ClientWONO#</td>
  18.             <td>#WorkshopWONO#</td>
  19.             <td>#dateFormat(WoRecdate,'dd/mm/yyyy')#</td>
  20.             <td>#dateFormat(QuotePDate,'dd/mm/yyyy')#</td>
  21.             <td>#numberFormat(Price, "(______,.00")#</td>
  22.             <td>#dateFormat(QuoteACDate, 'dd/mm/yyyy')#</td>
  23.             <td>#ResponseLevelFK#</td>
  24.             <td>#dateFormat(ActualCompDate, 'dd/mm/yyyy')#</td>
  25.             <td>#AssignedToFK#</td>
  26.             </tr>
  27.  
  28.  
  29.             </cfoutput>
  30.             </cfloop>
  31.             </table>
  32.  
  33.  
Cheers
Neil
Nov 18 '08 #3
acoder
16,027 Expert Mod 8TB
Assuming the sites are sorted and grouped in the query, e.g.
Expand|Select|Wrap|Line Numbers
  1. Site    Job
  2. 1       1
  3. 1       2
  4. 1       3
  5. 2       1
  6. 2       2
you can use a variable to store the current site, e.g. MYSITE1. Then compare with the SiteFK value. If it's equal, don't add a header. If it's a new site, add a header and set that variable to this new value.
Nov 18 '08 #4
ndeeley
139 100+
Acoder,

That's great - I'll give it a go.

Cheers
Neil
Nov 18 '08 #5
jKara
5
You can also use cfoutput's group attribute. Just order your results by "Site" first. Then use nested cfoutput tags and group by "Site" as well.

Expand|Select|Wrap|Line Numbers
  1. <cfquery ..>
  2.        SELECT  Site, Job,  ... other columns
  3.        FROM     Thetable
  4.        ORDER BY Site, Job, ... other columns
  5. </cfquery>
  6.  
  7. <cfoutput query="yourQuery" group="Site">
  8.           #Site#<br>
  9.           <cfoutput>
  10.                #Job#<br>
  11.           </cfoutput>
  12. </cfoutput>
  13.  
Nov 20 '08 #6
acoder
16,027 Expert Mod 8TB
Nice tip. Thanks for sharing!
Nov 20 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Curt Bousquet | last post by:
Hi; I'm brand new to PHP (just starting today to convert tons of ColdFusion/Access code to PHP/MySQL). There is a function in Coldfusion that I can't find an equivalent to in PHP. Here is what...
1
by: MLH | last post by:
I have a challenge... In a table I call tblStuff4Letters with 3 fields: , and . I have a report called rptOutboundCorrespondence that feeds off this table. Sorting & grouping is turned on in...
3
by: ahaque38 | last post by:
Hello. Using A2K SP3, I am having the following problem with a report using "Sorting and Grouping". I have recently added a grouping in the reports for "Category2<>'CONTRACTS'". I have...
8
by: Mike MacSween | last post by:
tblCourses one to many to tblEvents. A course may have an intro workshop (a type of event), a mid course workshop, a final exam. Or any combination. Or something different in the future. At...
27
by: Daniel Vallstrom | last post by:
I'm having problems with inconsistent floating point behavior resulting in e.g. assert( x > 0.0 && putchar('\n') && x == 0.0 ); holding. (Actually, my problem is the dual one where I get...
3
by: Jimmy | last post by:
Is there a way to sort/group a report based on the second column of a combo box, i.e. the text associated with the primary key number?
0
by: wingnut144 | last post by:
I have the following XML file: <?xml version="1.0" encoding="utf-8"?> <class> <sdate>9/10/07</sdate> <special>1,2</special> <inst>Max Callao</inst> <sdate>10/22/07</sdate>...
1
by: jjjoic | last post by:
Hi, I use Access 2003 to generate the back-end data for a ColdFusion report at work. The report is sorted by a column and based on the sorting, rankings are assigned to each row(i.e. the biggest...
4
by: kstevens | last post by:
I have a report, and on the report is a min, avg, and max query each with (ok who really cares) 20 or so records. At the footer of the report i would like to have a total. I requery for each...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.