If you are not concerned about the data being in cells like a table I would
use lists and use CSS for format the display, as in float all the <li>
elements so you have columns
<style>
ul {
margin:0px;
padding:0px;
list-style:none;
}
ul li {
width:150px;
float:left;
}
</style>
<ul>
<cfoutput query="get_members_advanced" group="contact_type_id">
<li>
<h2>#contact_type#</h2>
<cfoutput>#contact_surname#<br /><cfoutput>
</li>
</cfoutput>
</ul>
If you want to use tables this might give you something to play with. Only
this is you loose the original value of the column value as queryAddColumn()
dows not allow for values with spaces in them
<cffunction name="regroupQuery">
<cfargument name="query" type="query" required="true" />
<cfargument name="group" type="string" required="true" />
<cfargument name="columnName" type="string" required="true" />
<!---
- query : The query object
- group : The name of the column you want to group by
- columnName : The name of the query field value you want to
be the new column
--->
<cfset var result = queryNew("") />
<cfset var tmpArray = arrayNew(1) />
<cfset var i = "" />
<cfoutput query="arguments.query" group="#arguments.group#">
<cfset tmpArray = arrayNew(1) />
<cfoutput>
<cfset arrayAppend(tmpArray,
evaluate(arguments.columnName)) />
</cfoutput>
<cfset queryAddColumn(result,
replace(evaluate(arguments.group), " ", "_", "ALL"), tmpArray) />
</cfoutput>
<cfreturn result />
</cffunction>
-----Original Message-----
From: Brett Payne-Rhodes [mailto:[email protected]]
Sent: Saturday, 18 July 2009 12:53 PM
To: [email protected]
Subject: [cfaussie] Re: grouped query - display each group in new column
A table version is easy...
<table><tr>
<cfoutput query="get_members_advanced" group="contact_type_id">
<td><h2>#contact_type#</h2>
<cfoutput> #contact_surname# <br /></cfoutput>
</td>
</cfoutput>
</tr><table>
You can do it with divs and css as well I am sure... Hopefully this will
give you a start if that is what you need...
Brett
B)
seamus wrote:
> I have a grouped query which displays fine but in a single column.
> I want to display each group in a new column, but I can't work out how
> to do this
>
> I originally had this -
> <cfoutput query="get_members_advanced" group="contact_type_id">
> <h2>#contact_type# </h2>
> <cfoutput> #contact_surname# <br />
> </cfoutput>
> </cfoutput>
>
> But this gave me a single column - I want each new contact_type to
> display in a new column so if 4 different contact_types - 4 columns.
> And the number of columns will vary from 1 - 6 depending on the search
> criteria. Hope this makes sense?
>
> ta Seamus
>
> >
>
>
--
Brett Payne-Rhodes
Eaglehawk Computing
t: +61 (0)8 9371-0471
m: +61 (0)414 371 047
e: [email protected]
w: http://www.yoursite.net.au
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"cfaussie" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cfaussie?hl=en
-~----------~----~----~----~------~----~------~--~---