Toggling which columns are displayed from a database query using the CFDUMP tag in ColdFusion
Toggling which columns are displayed from a database query using the CFDUMP tag in ColdFusion
The following example show how you can toggle which database query columns are displayed by the <CFDUMP> tag in ColdFusion by specifying the show or hide attribute.
SELECT A.ARTISTID, A.FIRSTNAME, A.LASTNAME, A.ADDRESS, A.CITY, A.STATE
FROM ARTISTS A
query columnList:
#getArtists.columnList#
And the output of the <CFDUMP> tag is as follows:
query columnList:
ADDRESS,ARTISTID,CITY,FIRSTNAME,LASTNAME,STATEquery [Filtered — 2 of 6 columns shown]
[Record # 1]
FIRSTNAME: Aiden
LASTNAME: Donolan[Record # 2]
FIRSTNAME: Austin
LASTNAME: Weber[Record # 3]
FIRSTNAME: Elicia
LASTNAME: Kim[Record # 4]
FIRSTNAME: Jeff
LASTNAME: Baclawski[Record # 5]
FIRSTNAME: Lori
LASTNAME: Johnson
The previous example specifies which columns should be shown by setting the show attribute to “FIRSTNAME, LASTNAME”. If you wanted to prevent certain columns from being displayed by the <CFDUMP> tag, you could set the hide attribute, as seen in the following example:
SELECT A.ARTISTID, A.FIRSTNAME, A.LASTNAME, A.ADDRESS, A.CITY, A.STATE
FROM ARTISTS A
query columnList:
#getArtists.columnList#
And the output of the <CFDUMP> tag is as follows:
query columnList:
ADDRESS,ARTISTID,CITY,FIRSTNAME,LASTNAME,STATEquery [Filtered — 4 of 6 columns hidden]
[Record # 1]
FIRSTNAME: Aiden
LASTNAME: Donolan[Record # 2]
FIRSTNAME: Austin
LASTNAME: Weber[Record # 3]
FIRSTNAME: Elicia
LASTNAME: Kim[Record # 4]
FIRSTNAME: Jeff
LASTNAME: Baclawski[Record # 5]
FIRSTNAME: Lori
LASTNAME: Johnson
The following example show how you can toggle which database query columns are displayed by the <CFDUMP> tag in ColdFusion by specifying the show or hide attribute.
<cfquery name="getArtists" datasource="cfartgallery" maxRows="5"> SELECT A.ARTISTID, A.FIRSTNAME, A.LASTNAME, A.ADDRESS, A.CITY, A.STATE FROM ARTISTS A </cfquery> <cfoutput> <p>query columnList:<br/> #getArtists.columnList#</p> </cfoutput> <cfdump var="#getArtists#" metaInfo="false" format="text" show="FIRSTNAME, LASTNAME" /> |
And the output of the <CFDUMP> tag is as follows:
query columnList:
ADDRESS,ARTISTID,CITY,FIRSTNAME,LASTNAME,STATEquery [Filtered - 2 of 6 columns shown]
[Record # 1]
FIRSTNAME: Aiden
LASTNAME: Donolan[Record # 2]
FIRSTNAME: Austin
LASTNAME: Weber[Record # 3]
FIRSTNAME: Elicia
LASTNAME: Kim[Record # 4]
FIRSTNAME: Jeff
LASTNAME: Baclawski[Record # 5]
FIRSTNAME: Lori
LASTNAME: Johnson
The previous example specifies which columns should be shown by setting the show attribute to “FIRSTNAME, LASTNAME”. If you wanted to prevent certain columns from being displayed by the <CFDUMP> tag, you could set the hide attribute, as seen in the following example:
<cfquery name="getArtists" datasource="cfartgallery" maxRows="5"> SELECT A.ARTISTID, A.FIRSTNAME, A.LASTNAME, A.ADDRESS, A.CITY, A.STATE FROM ARTISTS A </cfquery> <cfoutput> <p>query columnList:<br/> #getArtists.columnList#</p> </cfoutput> <cfdump var="#getArtists#" metaInfo="false" format="text" hide="ARTISTID, ADDRESS, CITY, STATE" /> |
And the output of the <CFDUMP> tag is as follows:
query columnList:
ADDRESS,ARTISTID,CITY,FIRSTNAME,LASTNAME,STATEquery [Filtered - 4 of 6 columns hidden]
[Record # 1]
FIRSTNAME: Aiden
LASTNAME: Donolan[Record # 2]
FIRSTNAME: Austin
LASTNAME: Weber[Record # 3]
FIRSTNAME: Elicia
LASTNAME: Kim[Record # 4]
FIRSTNAME: Jeff
LASTNAME: Baclawski[Record # 5]
FIRSTNAME: Lori
LASTNAME: Johnson
Recent Posts
- Toggling the overview panel on a CFMAP tag in ColdFusion
- Listening for map errors on the CFMAP tag in ColdFusion
- Converting a database query to a WDDX packet using ColdFusion
- Toggling which columns are displayed from a database query using the CFDUMP tag in ColdFusion
- Dynamically adding columns to a database query using ColdFusion
- Adding the values in a database query column in ColdFusion
- Getting started with Arrays in ColdFusion
- Converting numbers between base 10 and base 16 using ColdFusion
- Getting started with Lists in ColdFusion
- Displaying a database query in a grid using the CFGRID tag in ColdFusion
Archives
- November 2010 (63)
- October 2010 (13)
Books
Categories
- Basics (4)
- CFAJAXIMPORT (1)
- CFAPPLICATION (1)
- CFCOMPONENT (1)
- CFDUMP (4)
- CFFEED (5)
- CFFILE (1)
- CFFORM (2)
- CFFUNCTION (1)
- CFARGUMENT (1)
- CFRETURN (1)
- CFHTTP (3)
- CFIF (1)
- CFELSE (1)
- CFIMAGE (3)
- CFINVOKE (1)
- CFINVOKEARGUMENT (1)
- CFLAYOUT (1)
- CFLAYOUTAREA (1)
- CFLOCATION (1)
- CFLOOP (6)
- CFMAP (10)
- CFMAPITEM (1)
- CFMEDIAPLAYER (11)
- CFOBJECT (1)
- CFOUTPUT (1)
- CFPARAM (1)
- CFPOD (4)
- CFQUERY (11)
- CFSCRIPT (2)
- CFTABLE (1)
- CFCOL (1)
- CFTRY (1)
- CFCATCH (1)
- CFWDDX (1)
- CFXML (1)
- CGI (2)
- jQuery (2)
- Uncategorized (6)
Tags
action arrayAppend() arrayAvg() arrayLen() arraySum() ceiling() centerAddress CGI ColdFusion.Map ColdFusion.Mediaplayer collapsible condition createDate() datasource dateAdd() dateFormat() delimters firstRowAsHeaders fix() format from hideBorder index jQuery listToArray() maxRows name onLoad onStart output pi() query querySetCell() recordCount round() setCenter() source step title to top type url valueList() xmlVar



