6 Replies Latest reply on Dec 20, 2006 12:23 PM by MikerRoo

    grouping result output with table format

    HandersonVA
      I'd like to print out one vendorname for several call numbers and amont paids instead of displaying duplicate vendoranme each line. When i run the code below, the table format came out wrong. I did print vendor name once, but next line of the call number should be positioned under the call number header, but it goes under the vendor name again.
      anyoen can help me to correct this data display?

      Expected output:
      VENDOR NAME | CALL# | AMT PAID
      --------------------------------------------------------------------------------------
      VERIZON WIRELES | CALLNO01 | $500.00
      ----------------------------------------------------------------------------------------
      empty space |CALLNO02 | $200 |
      -------------------------------------------------------------------------------------
      empty space |CALLNO03 | $50 |
      ------------------------------------------------------------------------------------
      empty space |CALLNO04 | $10 |
      ------------------------------------------------------------------------------------



      --------- wrong output result for code below --------------
      ------------------------------------------------------------------------------------------
      VENDOR NAME | CALL# | AMT PAID
      --------------------------------------------------------------------------------------
      VERIZON WIRELES | CALLNO01 | $500.00
      ----------------------------------------------------------------------------------------
      CALLNO02 | $200 |
      -------------------------------------------------------------------------------------
      CALLNO03 | $50 |
      ------------------------------------------------------------------------------------
      CALLNO04 | $10 |
      ------------------------------------------------------------------------------------

      -----------------code------------------------------------
      <tr align="center">
      <td width="3%"><b>VENDOR NAME</b></td>
      <td width="15%"><b>CALL#</B></td>
      <td width="21%" align="right"><b>AMT PAID</b></td>
      </tr >
      <cfoutput group="vendorname">
      <tr align="center" valign="top">
      <td align="left">#UCase(otrQry01.vendorfullname)#</td>
      <cfoutput>
      <td>#UCase(otrQry01.calllnumber)#</td>
      <td align="right">#DollarFormat(otrQry01.amountpaid)#</td>
      </tr>
      </cfoutput>
      </cfoutput>
        • 1. Re: grouping result output with table format
          Charlie Griefer Level 1
          dump your query and make sure you have a vendorfullname value.

          change this line:
          <td align="left">#UCase(left(otrQry01.vendorfullname, 15))#</td>

          to:
          <td align="left"><cfif len(trim(otrQry01.vendorname)) GT 0>#UCase(left(otrQry01.vendorfullname, 15))#<cfelse>N/A</cfif></td>

          post the results back.
          • 2. Re: grouping result output with table format
            Dan Bracuk Level 5
            For what you are trying to do, I think you have to replace the group attribute with some if/else logic. If it's a new vendor, display it, otherwise display an empty table cell. There might be a more elegant way, but I can't think what that would be.
            • 3. grouping result output with table format
              Charlie Griefer Level 1
              ah wait... i think i see. you're grouping on VendorName, so VendorName should not be within the same <cfoutput> group as the rest of the data.

              try this:
              • 4. grouping result output with table format
                HandersonVA Level 1
                Dan, sounds great. I will try. thanks.
                CJ, it displays good, but the first row also should display call number next to the vendor name. thanks for your help.
                The output for your code displays as below: (The second row should go to the same line of the vendor name)

                VENDOR NAME | CALL# | AMT PAID
                --------------------------------------------------------------------------------------
                VERIZON WIRELES | empty space
                ----------------------------------------------------------------------------------------
                empty space | CALLNO01 | $500.00
                ----------------------------------------------------------------------------------------
                empty space |CALLNO02 | $200 |
                -------------------------------------------------------------------------------------
                empty space |CALLNO03 | $50 |
                ------------------------------------------------------------------------------------
                empty space |CALLNO04 | $10 |
                ------------------------------------------------------------------------------------

                Expected output:
                VENDOR NAME | CALL# | AMT PAID
                --------------------------------------------------------------------------------------
                VERIZON WIRELES | CALLNO01 | $500.00
                ----------------------------------------------------------------------------------------
                empty space |CALLNO02 | $200 |
                -------------------------------------------------------------------------------------
                empty space |CALLNO03 | $50 |
                ------------------------------------------------------------------------------------
                empty space |CALLNO04 | $10 |
                ------------------------------------------------------------------------------------
                • 5. Re: grouping result output with table format
                  Charlie Griefer Level 1
                  k...the expected output helps.

                  this is kludgy...but like Dan said, I can't think of a better way right now.
                  • 6. Re: grouping result output with table format
                    MikerRoo Level 1
                    CJ's solution is almost the best, given that layout and discarding fancy CSS tricks.

                    However, this variant should be slightly more efficient...