0

handy utility function: queryToHTMLTable()

ColdFusion

For when you want to output any query object, no matter how many columns or rows it has, to an HTML table:

 

Thanks to Qasim Rasheed, as this function is loosely based off his excellent and smokin' fast queryToCsv2().  

tags:
ColdFusion
 
Sweet, then throw in a little sorttable.js javascript from http://kryogenix.org/code/browser/sorttable/ and make the table sortable by the column names.
 
posted 964 days ago
Add Comment Reply to: this comment OR this thread
 
Sam Farmer said:
 
Take a look at cftable as well for a very quick (and dirty) solution.
 
posted 964 days ago
Add Comment Reply to: this comment OR this thread
 
cfZen said:
 
Aaron - nice DHTML... I'll add it to my bag o' tricks.

Sam - good point, but I never liked cftable much and you have to explicitly define 1 or more cfcol tags, but it has it's uses I suppose. The idea with queryToHTMLTable() is that it has the simplicity of passing a query object to cfdump (i.e. queryToHTMLTable( qryMyUninterestingInfo )), but without the lovely pink colors and unnecessary markup. Also, it dynamically figures out the column names and how many. And you can override the column names with something more friendly. Personally, I've found it useful in an ad-hoc reporting system where the was dynamically generated via CF and I didn't know beforehand how many columns were going to be needed. ;)
 
posted 964 days ago
Add Comment Reply to: this comment OR this thread
 
 
"make the table sortable by the column names. "

should have read, "sortable by clicking on the column names" or something like that anyways...
 
posted 964 days ago
Add Comment Reply to: this comment OR this thread
 
Sam Farmer said:
 
cfzen -- good points...I would especially avoid using cfdump for anything other than debugging and partly due to the colors...

Aaron -- there are a couple of custom tags out there that incorporate the spry feature for doing that. I've found spry pretty easy to manipulate as well.
 
posted 964 days ago
Add Comment Reply to: this comment OR this thread
 

Search

Aaron  Longnion

The Hague, NL