Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possibe to group the cfouput??

Status
Not open for further replies.

johnhig

MIS
Jun 25, 2007
54
US
Hi Everyone,
I have pasted a copy of my code below. All is well with the code and it works just fine, but now one of my end users is asking if I can group the output of data by Division.

I am not sure how to do this with the existing code. I have tried a few different ways but am not getting the results I would like.

Can I do this with the exisitng code, or do I need to rewrite it?

Thanks John


<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="2" CLASS="wrapper">
<TR>
<CFIF ParameterExists(Sort) AND Sort IS "DESC">
<CFSET Sort="ASC">
<CFELSE>
<CFSET Sort="DESC">
</CFIF>
<CFOUTPUT>
<TD NOWRAP CLASS="title"><FONT CLASS="ColumnFont"><A HREF="/intranet/projecttracking/taskselecttest.cfm?OrderBy=division&Sort=#Sort###Tasks"><FONT COLOR="444444">Division</FONT></A></FONT></TD>
<TD NOWRAP CLASS="title"><FONT CLASS="ColumnFont"><A HREF="/intranet/projecttracking/taskselecttest.cfm?OrderBy=ProjectID&Sort=#Sort###Tasks"><FONT COLOR="444444">RO</FONT></A></FONT></TD>
<TD NOWRAP CLASS="title"><FONT CLASS="ColumnFont"><A HREF="/intranet/projecttracking/taskselecttest.cfm?OrderBy=TaskID&Sort=#Sort###Tasks"><FONT COLOR="444444">TaskID</FONT></A></FONT></TD>
<TD NOWRAP CLASS="title"><FONT CLASS="ColumnFont"><A HREF="/intranet/projecttracking/taskselecttest.cfm?OrderBy=Customer&Sort=#Sort###Tasks"><FONT COLOR="444444">Customer</FONT></A></FONT></TD>
<TD NOWRAP CLASS="title"><FONT CLASS="ColumnFont"><A HREF="/intranet/projecttracking/taskselecttest.cfm?OrderBy=Name&Sort=#Sort###Tasks"><FONT COLOR="444444">Unit</FONT></A></FONT></TD>
<TD NOWRAP CLASS="title"><FONT CLASS="ColumnFont"><A HREF="/intranet/projecttracking/taskselecttest.cfm?OrderBy=Status&Sort=#Sort###Tasks"><FONT COLOR="444444">Status</FONT></A></FONT></TD>
<TD NOWRAP CLASS="title"><FONT CLASS="ColumnFont"><A HREF="/intranet/projecttracking/taskselecttest.cfm?OrderBy=Assigned&Sort=#Sort###Tasks"><FONT COLOR="444444">Assigned</FONT></A></FONT></TD>
<TD NOWRAP CLASS="title"><FONT CLASS="ColumnFont"><A HREF="/intranet/projecttracking/taskselecttest.cfm?OrderBy=JobType&Sort=#Sort###Tasks"><FONT COLOR="444444">Priority</FONT></A></FONT></TD>
<TD NOWRAP CLASS="title"><FONT CLASS="ColumnFont"><A HREF="/intranet/projecttracking/taskselecttest.cfm?OrderBy=Priority&Sort=#Sort###Tasks"><FONT COLOR="444444">Type</FONT></A></FONT></TD>
<TD NOWRAP CLASS="title"><FONT CLASS="ColumnFont"><A HREF="/intranet/projecttracking/taskselecttest.cfm?OrderBy=Percentage&Sort=#Sort###Tasks"><FONT COLOR="444444">Progress</FONT></A></FONT></TD>
<TD NOWRAP CLASS="title"><FONT CLASS="ColumnFont"><A HREF="/intranet/projecttracking/taskselecttest.cfm?OrderBy=Schedule&Sort=#Sort###Tasks"><FONT COLOR="444444">Sch.
Date </FONT></A></FONT></TD>
<TD NOWRAP CLASS="title"><FONT CLASS="ColumnFont"><A HREF="/intranet/projecttracking/taskselecttest.cfm?OrderBy=DueDate&Sort=#Sort###Tasks"><FONT COLOR="444444">Est. Complete <br />
Date</FONT></A></FONT></TD>
<TD NOWRAP CLASS="title"><FONT CLASS="ColumnFont"><A HREF="/intranet/projecttracking/taskselecttest.cfm?OrderBy=site&Sort=#Sort###Tasks"><FONT COLOR="444444">Job Site <br />
Location</FONT></A></FONT></TD>
<TD NOWRAP CLASS="title"><FONT CLASS="ColumnFont"><A HREF="/intranet/projecttracking/taskselecttest.cfm?OrderBy=site&Sort=#Sort###Tasks"><FONT COLOR="444444">Follow Up <br />
Required</FONT></A></FONT></TD>
</CFOUTPUT> </TR>
<TR>
<TD NOWRAP CLASS="DataTD" ID="firstcolumnsolid"><a href="/intranet/projecttracking/projectdetails.cfm?Reason=Modify&ProjectID=#ProjectID#"><font class="DataFont">#division#</font></a></TD>
<TD NOWRAP CLASS="DataTD" ID="firstcolumnsolid"><A HREF="/intranet/projecttracking/projectdetails.cfm?Reason=Modify&ProjectID=#ProjectID#"><FONT CLASS="DataFont">#ProjectID#</FONT></A></TD>
<TD NOWRAP CLASS="DataTD"><A HREF="/intranet/projecttracking/taskdetails.cfm?Reason=Modify&ProjectID=#ProjectID#&TaskID=#TaskID#"><FONT CLASS="DataFont">#TaskID#</FONT></A></TD>
<TD NOWRAP CLASS="DataTD"><A HREF="/intranet/projecttracking/taskdetails.cfm?Reason=Modify&ProjectID=#ProjectID#&TaskID=#TaskID#"><FONT CLASS="DataFont">#Customer#</FONT></A></TD>
<TD NOWRAP CLASS="DataTD"><A HREF="/intranet/projecttracking/taskdetails.cfm?Reason=Modify&ProjectID=#ProjectID#&TaskID=#TaskID#"><FONT CLASS="DataFont">#Unit#<br />#NonEESUnit#</FONT></A></TD>
<TD NOWRAP CLASS="DataTD"><FONT CLASS="DataFont">#Status#</FONT></TD>
<TD NOWRAP CLASS="DataTD" ID="lastcolumnsolid"><FONT CLASS="DataFont">
<CFSET ColorToUse="">
<CFLOOP INDEX="AssignedNumber" FROM="1" TO="#ListLen(Assigned, Comma)#">
<CFIF CompletedUsers CONTAINS "#ListGetAt(Assigned, AssignedNumber, Comma)#">
<CFSET Color="<FONT COLOR='E10000'><B>">
<CFSET ColorEnd="</B></FONT>">
<CFELSEIF ColorToUse IS "Black">
<CFSET Color="">
<CFSET ColorEnd="">
<CFELSE>
<CFSET Color="<FONT COLOR='00A600'><B>">
<CFSET ColorEnd="</B></FONT>">
<CFSET ColorToUse="Black">
</CFIF>
#Color##ListGetAt(Assigned, AssignedNumber, Comma)##ColorEnd#<CFIF AssignedNumber IS NOT "#ListLen(Assigned, Comma)#"><BR></CFIF>
</CFLOOP>
</FONT></TD>
<TD NOWRAP CLASS="DataTD"><FONT CLASS="DataFont">#Priority#</FONT></TD>
<TD NOWRAP CLASS="DataTD"><FONT CLASS="DataFont">#JobType#</FONT></TD>
<TD NOWRAP CLASS="DataTD"><FONT CLASS="DataFont">
<TABLE WIDTH="80" BORDER="0" ALIGN="left" CELLPADDING="0" CELLSPACING="0">
<TR>
<TD ROWSPAN="3" BGCOLOR="000000"><IMG SRC="/intranet/images/spacer.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>
<TD COLSPAN="2" BGCOLOR="000000"><IMG SRC="/intranet/images/spacer.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>
<TD ROWSPAN="3" BGCOLOR="000000"><IMG SRC="/intranet/images/spacer.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>
</TR>
<TR>
<CFIF Percentage IS "0">
<CFSET Color="">
<CFELSE>
<CFSET Color=" BGCOLOR='E10000'">
</CFIF>
<TD WIDTH="#Percentage#%"#Color#><IMG SRC="/intranet/images/spacer.gif" WIDTH="1" HEIGHT="10" BORDER="0"></TD>
<CFIF Percentage IS "100">
<CFSET Color=" BGCOLOR='E10000'">
<CFELSE>
<CFSET Color="">
</CFIF>
<TD WIDTH="#100 - Percentage#%"#Color#><IMG SRC="/intranet/images/spacer.gif" WIDTH="1" HEIGHT="10" BORDER="0"></TD>
</TR>
 
Are you looping through a qquery or what? If so you didn't include that code. What you provided is only outputting one row of whatever data set division is in.



Lyndon

---People Remember about 10% of what you say ---They never forget how you made them feel. Covey
 
I don't have a loop just an output. Is a loop what I need to make the output group the division?
 
Are you outputting a query? If so are you using
<cfoutput query="..."> or <cfloop query="...">?

You can use <cfoutput query="..."> with the "group" attribute to group your results by division.
 
show all of your code.

Lyndon

---People Remember about 10% of what you say ---They never forget how you made them feel. Covey
 
show all of your code???

whoa, wait a sec, did you see all the code in the first post? and you want more of that?

how about just suggesting that he use CFOUTPUT with the QUERY= option?

;-)

r937.com | rudy.ca
 
You can use

<cfoutput group="mygroup" query="myquery"></cfoutput>

where mygroup is the field you want to group by.

Coldfusion help has a good example of this.
 
show all of your code???

whoa, wait a sec, did you see all the code in the first post? and you want more of that?"

Ah...haha...

I come here for the comedy now-days :)

"Coldfusion help has a good example of this."

Yes it does. I wish I could give stars to everyone that suggests to Read The Fine Manual

Kevin
 
Yes, sometimes its laziness :) But sometimes people don't know the correct term for what they want to accomplish, so they have difficulty finding information in the documentation.
 
I'm a lot closer to newbie status than most of you who help. I don't mind helping those who and obviously just starting out. It actually helps me to learn more.

But, when they never come back and acknowledge if they were helped it is very frustrating.

Lyndon

---People Remember about 10% of what you say ---They never forget how you made them feel. Covey
 
When I say read the manual, I mean read it. Don't wait until you need help and try to find a function or tag. READ the CFML reference. Start at the beginning, notice how the functions and tags are grouped. Read through the function and tag specs and see what is available, what arguments they take, what they return. Get them in your head so you can use them. You'll start to see situations where you should be using function-x instead of ham-fisting function-a and function-b and function-c in some sort of perverted nested loop just to build an array from a query or something simple.

Kevin
 
> READ the CFML reference

Now that's comedy ;)

You're right of course. I used to suggest RTM as well as picking a few functions/tags a day and doing some examples to help solidify your understanding. Amazing how many people weren't receptive to the idea ;) <shrug>
 
I enjoyed it. I learned.

I wish everyone had that attitude. IMO its even more important with the newer versions, as they're packed with a lot more functionality than in the early Allaire days ;)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top