Skip to main content
September 24, 2008
Answered

Multiple cfoutput groups

  • September 24, 2008
  • 2 replies
  • 3237 views
I have a report and need the results displayed in multiple groups. From one query result set I am using the cfoutput tag with the query and group attributes to display the results (types and number of workers) by mealtime (Lunch and Dinner). This works fine but I also need the types of workers grouped (with each mealtime) by which part of the restaurant they work in (front, back, management). To do this within the aforementioned cfoutput tag I added another cfoutput tag with a second group option. This almost worked but the problem is that I am only getting the first row of data from each one of the subgroups (where they work) and not all of the rows. I tried adding the query attribute to the nested cfquery attribute but that is not allowed.

Has any one used multiple group attributes in nested cfoutput tags? Can it be done? If so, what am I don't wrong. If not is there another way?

Thanks,

Jason
    This topic has been closed for replies.
    Correct answer
    CF won't allow you to nest two query driven cfoutput tags. I posted this question to my cfgroup and they were able to answer it.

    ANSWER:
    At the lowest level, you will want a simple cfoutput without a group on it.

    <cfoutput query="qry_my_query" group="outer_grouping_column">

    <cfoutput group="inner_grouping_column">

    <cfoutput>

    </cfoutput>

    </cfoutput>

    </cfoutput>

    Answered by Matt Jones and Brad Wood of the KCDevCore group. Thanks guys!

    2 replies

    Inspiring
    September 24, 2008
    jasonpresley wrote:
    > Has any one used multiple group attributes in nested cfoutput tags?

    Yes, many times.

    > Can it be done?

    Of course, that is the whole point of the group attribute.

    > If so, what am I don't wrong.

    I don't know. You did not show what you actually did!

    > If not is there another way?

    Several, but it does not sound like they are necessary.


    If I had to *guess* from your imprecise description, it sounds like you
    have forgotten the final inner <cfoutput> block without any group
    parameter.

    The basic structure is as follows:

    <cfoutput query="aQuery" group="aColumn">
    Stuff to output once per value of aColumn

    <cfoutput group="bColumn">
    Stuff to output once per value of bColumn
    .
    .
    .
    <cfoutput group="nColumn">
    Stuff to output once per value of nColumn

    <cfoutput>
    Stuff to output for every record in the query
    </cfoutput>

    Stuff to output oncer per value of nColumn
    </cfoutput>
    Stuff to output once per value of bColumn
    </cfoutput>
    Stuff to output once per value of aColumn
    </cfoutput>

    Inspiring
    September 24, 2008
    What happened when you tried it?
    Correct answer
    September 24, 2008
    CF won't allow you to nest two query driven cfoutput tags. I posted this question to my cfgroup and they were able to answer it.

    ANSWER:
    At the lowest level, you will want a simple cfoutput without a group on it.

    <cfoutput query="qry_my_query" group="outer_grouping_column">

    <cfoutput group="inner_grouping_column">

    <cfoutput>

    </cfoutput>

    </cfoutput>

    </cfoutput>

    Answered by Matt Jones and Brad Wood of the KCDevCore group. Thanks guys!