Skip to main content
WolfShade
Legend
September 6, 2017
Answered

Is there a 'lookahead' when using the GROUP attribute of CFOUTPUT?

  • September 6, 2017
  • 1 reply
  • 313 views

Hello, all,

I was just wondering if there is a native lookahead when using the GROUP attribute of CFOUTPUT to determine things like how many records are in the group?

For example, let's say I had a query like so:

CATEGORY                      SPEC                 ROLE

CAT I                         SPEC I               ROLE I

CAT I                         SPEC I               ROLE II

CAT I                         SPEC I               ROLE III

CAT I                         SPEC II              ROLE Ia

CAT I                         SPEC II              ROLE IIa

CAT I                         SPEC III             ROLE Ib

CAT II                        SPEC IV              ROLE Ic

CAT II                        SPEC IV              ROLE Id

CAT II                        SPEC V               ROLE Ie

CAT III                       SPEC VI              ROLE If

CAT III                       SPEC VI              ROLE Ig

In my CFOUTPUT, I give the first tag both the query name and the group="CATEGORY"; the second CFOUTPUT will just have group="SPEC"; the third CFOUTPUT has no attributes.

Is there a way that I can tell ahead of time that CAT I, SPEC I has three records (ROLE I, II, and III)?

V/r,

^ _ ^

    This topic has been closed for replies.
    Correct answer WolfShade

    Apparently, no.

    However, I did find a thread on SO that had a nice workaround.  (Granted, maybe not so nice if you're grabbing 1,000,000+ records.)

    <cfoutput query="foo" group="CATEGORY">

        #category#

        <cfoutput group="SPEC">

              <br />#spec#

              <cfset numrecs = 0 /><cfoutput><cfset numrecs++ /></cfoutput>

              <br />#numrecs# records:<br />

              <cfoutput><br />#ROLE#</cfoutput><br /><br />

         </cfoutput>

    </cfoutput>

    Hope this helps anyone else seeking something like this.

    V/r,

    ^ _ ^

    1 reply

    WolfShade
    WolfShadeAuthorCorrect answer
    Legend
    September 6, 2017

    Apparently, no.

    However, I did find a thread on SO that had a nice workaround.  (Granted, maybe not so nice if you're grabbing 1,000,000+ records.)

    <cfoutput query="foo" group="CATEGORY">

        #category#

        <cfoutput group="SPEC">

              <br />#spec#

              <cfset numrecs = 0 /><cfoutput><cfset numrecs++ /></cfoutput>

              <br />#numrecs# records:<br />

              <cfoutput><br />#ROLE#</cfoutput><br /><br />

         </cfoutput>

    </cfoutput>

    Hope this helps anyone else seeking something like this.

    V/r,

    ^ _ ^