11
Dec
03

DisplayInColumns ColdFusion custom tag

I wrote a DisplayInColumns custom tag recently for a project and have found it to be extremely useful. The tag minimally accepts as parameters a query and a formatter and optionally includes the number of columns and table attributes. The formatter is a UDF that is called to format each record in the query–referred to as a callback.

With the DisplayInColumns custom tag we can display a record set of names in three columns with the following code (which includes the sample data).

s = "Andrew,Andy,Ba,Bach,Brad,Chafic,Chau,David,Feng,Jay,Jim,Laura" &
"Lucas,Marilyn,Mindy,Nancy,Oanh,Rosa,Sam,Shelly,Thuy,Wang";

q = queryNew("");
queryAddColumn(q, "name", listToArray(s));

This code does three things.

  1. It sets up the source data which for demonstration purposes we’re hard coding.
  2. It creates a myFormatter UDF which formats each record by displaying the record number and the value of the “name” column.
  3. It calls the DisplayInColumns custom tag to display the data in three columns.

The result of this code follows is this table.

s = “Andrew,Andy,Ba,Bach,Brad,Chafic,Chau,David,Feng,Jay,Jim,Laura” &
“Lucas,Marilyn,Mindy,Nancy,Oanh,Rosa,Sam,Shelly,Thuy,Wang”;

q = queryNew(”");
queryAddColumn(q, “name”, listToArray(s));

The advantage of this custom tag is that by using a callback UDF it is extremely flexible in presentation. The tag also supports providing attributes for the table elements it creates.

You can view or download the tag.


4 Responses to “DisplayInColumns ColdFusion custom tag”


  1. 1 capital home loans Nov 2nd, 2004 at 3:02 pm

    Hello there,

    Iwas browsing the web and found this blog. Some interesting quotes. Keep them coming!

    Alice
    capital home loans

  2. 2 Motrin Nov 3rd, 2004 at 5:29 am

    Hi, You should check out Motrin

  3. 3 Bob Staple Nov 17th, 2004 at 6:21 am

    Guten Tag - Hier ist ein sehr schooner Site. Cheap Staples

    Danke!
    Bob Staple

  4. 4 Caiek Feb 3rd, 2007 at 8:09 am

    So much spam (

Comments are currently closed.