Welcome!

ColdFusion Authors: Greg Ness, Liz McMillan, Pat Romanski, Andreas Grabner, David Strom

Related Topics: ColdFusion

ColdFusion: Article

Ask the Training Staff

Ask the Training Staff

Well, the new millennium is finally here (sorry for those of you who thought it started last year) and with it comes many unanswered and some unanswerable questions.

Fortunately for you CF developers out there, your CF questions don't have to fall into the category of unanswerable.... Send them in, and we'll get them answered for you. Here are some recent questions to kick off the new year:

Q:I need to do a three-layer grouping in a report to properly display my information. In MS Access this is no problem; you just use the grouping in the report and work your way through as many levels as you need (to a point). But CF seems to be limited to only two layers (see code that follows). How can I get three or even more layers to display?

<CFOUTPUT query="queryname" group="query_column">
#toplayer#
<CFOUTPUT>
#nextlayer#
<CFOUTPUT>
</CFOUTPUT>

A:Actually, you can go as deep as you want; you just need to keep specifying the GROUP attribute for each level until the last. Remember to sort your query (using the ORDER BY clause in your SQL) by the columns in which you plan to group the data, as shown here:

<CFQUERY NAME="queryname" DATASOURCE="datasourcename">
SELECT column1, column2, column3
FROM tablename
ORDER BY column1, column2, column2
</CFQUERY>

<CFOUTPUT query="queryname" group=" column1">
#toplayer#
<CFOUTPUT GROUP=" column2>
#nextlayer#
<CFOUTPUT GROUP=" column3">
#nextlayer#
<CFOUTPUT>
#nextlayer#
</CFOUTPUT>
</CFOUTPUT>
<CFOUTPUT>
</CFOUTPUT>

Q:I just upgraded my version of MS Internet Explorer from 5.01 to 5.5, and now CF Studio won't show me any of my page changes unless I click the refresh button in Studio's browser. This is very annoying. Is there any way to get Studio to stop this behavior?

A:Yes! The problem actually has nothing to do with Studio. The problem lies within the way IE 5.5 caches pages. To fix this, open up IE and go to the "Tools" menu, then choose "Internet Op-tions." In the "Temporary Internet files" section, click on the "Settings" button, then tell IE to "Check for newer versions of stored pages" on "Every visit to the page." This will fix the problem of browsing in Studio, because IE will now detect that the page has been modified. Remember that the internal browser for Studio is actually just Internet Explorer.

Q:In my cfm page, I have a condition where I need to do a CFLOCATION to a page in a different frame. You can't specify the "target" attribute. Is there a way to do this?

A:No, not using CFLOCATION. The problem here is that ColdFusion is executed entirely on the server with no knowledge of or ability to control things that happen in a browser. CFLOCATION is a server-side redirect. What you need to do is a client-side redirect, which you can accomplish by using a simple JavaScript statement. Where you would have placed the CFLOCATION tag, put in this JavaScript: <SCRIPT> parent.framenamehere. location.href='newpage.cfm'</ SCRIPT> (replace "framenamehere" with the actual name of your frame).

Q:I seem to remember you showed us in class how to display alternating row colors in a table that's created by <CFOUTPUT>, but I don't remember the code. How can I do this?

A:Here's one easy way:

<CFOUTPUT QUERY="myQuery">
<TR <CFIF myQuery.CurrentRow MOD 2>BGCOLOR="Yellow"</CFIF>>
<TD>Some data here</TD>
</TR>
</CFOUTPUT>

Please send questions about ColdFusion (CFML, CF Server, or CF Studio) to AskCFDJ@sys-con.com.

More Stories By Bruce Van Horn

Bruce Van Horn is president of Netsite Dynamics, LLC, a certified ColdFusion developer/instructor, and a member of the CFDJ International Advisory Board.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.