3 Replies Latest reply on May 9, 2006 4:42 PM by dempster

    Using <cfoutput group=""> within a table

    EdmondsM
      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.

        • 1. Re: Using &lt;cfoutput group=&quot;&quot;&gt; within a table
          Dan Bracuk Level 5
          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.
          • 2. Re: Using &lt;cfoutput group=&quot;&quot;&gt; within a table
            EdmondsM Level 1
            Any one else have any ideas??
            • 3. Re: Using &lt;cfoutput group=&quot;&quot;&gt; within a table
              dempster Level 1
              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.