Skip to main content
Inspiring
May 17, 2011
Question

Break dynamic data into sections in a table

  • May 17, 2011
  • 2 replies
  • 849 views

I have some data that is being dynamically output into a table. I have multiple line items for each ECO Number on their own rows. For instance:

ECOPart Number
Revision
1C4520A
1C5680B
1C8902A
2C5000B
2C5050C
2C4950A

How can I put in a blank line between the ECO sections of data. For instance, after the third line of ECO 1, there should be a blank line so I can break each section apart of ECO's. It should look like this:

Header 1Header 2Header 3
1C4520A
1C5680B
1C8902A
2C5000B
2C5050C
2C4950A

I have tried putting another row in the table, but it just puts a row after all this dynamic info. I've tried breaks everywhere too. So how do I keep the sections together and then break each section apart?

Andy

    This topic has been closed for replies.

    2 replies

    ilssac
    Inspiring
    May 17, 2011

    You are looking for nested outputs with the group property.

    <cfoutput query="aQuery" group="aColumn">

    <!--- output stuff for each value of aColumn --->

    <cfoutput group="bColumn">

    <!--- output stuff for each value of bColumn --->

    <cfoutput>

    <!--- output stuff for each and every row of aQuery --->

    </cfoutput>

    <!--- output stuff for each value of bColumn --->

    </cfoutput>

    <!--- output stuff for each value of aColumn --->

    </cfoutput>

    Full details can be found in the documenation.

    Inspiring
    May 17, 2011

    I have a cfloop query though, and not an output query. Will the group fuction work with cfloops? It seems not to since it gives me error on the page.  It says the tag does not allow the attribute group.

    Here's what I have:

    <cfloop query="PNRBOMSearch">

    <tr>

    <td align="center">
    <cfif ECID is not "">
    <!--- <a href="item_display.cfm?ECID=#ECID#">#ECID#</a> --->
    #ECID#
    <cfelse>
     </cfif>
    </td>

    <td width="auto">
    <cfif Part_Number Is Not "">
    #Part_Number#
    <cfelse>
     </cfif>
    </td>


    <td align="center">
    <cfif PNR_Initials Is Not "" and PNR_Initials EQ cookie.UserInitials>
    #cookie.UserInitials#
    <cfelse>
     
    </cfif>
    </td>

    <td>
    <cfif PNR_Initials Is Not "" and PNR_Initials EQ cookie.UserInitials>
    <input type="text" name="PNR_Rev" value="#Trim(PNR_Rev)#" size="4">
    <cfelse>
     
    </cfif>
    </td>

    <td align="center">
    <cfif BOM_Initials Is Not "" and BOM_Initials EQ cookie.UserInitials>
    #cookie.UserInitials#
    <cfelse>
     
    </cfif>
    </td>

    <td>
    <cfif BOM_Initials Is Not "" and BOM_Initials EQ cookie.UserInitials>
    <input type="text" name="BOM_Rev" value="#Trim(BOM_Rev)#" size="4">
    <cfelse>
     
    </cfif>
    </td>


    <td>
      <input type="radio" name="PNR_Queue_TM" value="1"
      <cfif PNR_Queue_TM EQ 1>checked</cfif>>Yes  
      <input type="radio" name="PNR_Queue_TM" value="0"
      <cfif PNR_Queue_TM EQ 0>checked</cfif>>No
    </td>

    </tr>

    <cfelse>
    </cfif>

    </cfloop>

    Thanks.

    Andy

    ilssac
    Inspiring
    May 17, 2011

    Is there are reason you can not change your <cfloop query...> to <cfoutput query...>?  They are often, but NOT always, interchangeable.

    IF not, then you get the pleasure of creating your own nested looping functionality.  It basically just takes some judicious use of if statements and storing current values of important columns.

    Inspiring
    May 17, 2011

    The group attribute of cfoutput would be useful.  So would the colspan attribute of <td>.