• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Using <cfoutput group=""> within a table

New Here ,
May 08, 2006 May 08, 2006

Copy link to clipboard

Copied

Hi All, I having problems with <cfoutput group> within a table. I can get the data to display the information correctly. But if a person has more than one record it displays the other records lined up with the name not with the other corresponding data.

wrong way

Name Position Date Hired
Tom Stock 2/5/05
Stock 2 3/5/06
Billy Driver 5/14/03

it should be like this

Name Position Date Hired
Tom Stock 2/5/05
Stock 2 3/5/06
Billy Driver 5/14/03

-----------------------------------------------------------------------------------
Here is the code that I am using.

TOPICS
Advanced techniques

Views

307

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 08, 2006 May 08, 2006

Copy link to clipboard

Copied

If the date hired never changes, you can do this sort of thing.
<cfoutput query="yourquery" group="name">
<tr>
<td>#name#</td>
<td>#hiredate#</td>
<td>
<cfoutput>
#position#<br>
</cfoutput>
</td>
</tr>
</cfoutput>

But if the same person can have more than 1 hire date, you'll need a totally different approach.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 09, 2006 May 09, 2006

Copy link to clipboard

Copied

Any one else have any ideas??

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 09, 2006 May 09, 2006

Copy link to clipboard

Copied

LATEST
Your problem is that when a person has multiple records, you are not outputting the tags you need to start a new row and have a table cell in the name column. That throws your columns out of whack.

You can fix this by setting an empty string value before you start the nested CFOUTPUT tags, then setting that value to the table tags for subsequent loops.

Something like this:

<CFSET rowstart = "">
<cfoutput>
#rowstart#
<td width="200px">#Description#</td>
<td width="400px">#Branch#</td>
<td align="center"><cfif #Terminated# EQ 0>Active<cfelse>Inactive</cfif></td>
<td>#DateFormat(DateHire, 'mm/dd/yyyy')#</td>
<td align="center"><cfif #terminated# EQ 0>--<cfelse>#DateFormat(lastActionDate, 'mm/dd/yyyy')#</cfif></td>
</tr>
<CFSET rowstart = "<tr class='#Class#'><td></td>">
</cfoutput>

The first time around, rowstart is blank. But for the second and subsequent records in the group, it displays the tr and td tags.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation