Exploring ColdFusion 9: The Four New Data Types in CFGrid
ColdFusion 9ColdFusion 9 brings four new data types to the html cfgrid. As the docs state:
ColdFusion 9: Added boolean, date, numeric, and string_noCase to the
type attribute values supported in HTML grids
Lets take a look at these new types. Here's a sample query from the art table that I added a date to and called it, well, aDate:

I'll display these using the following cfgridcolumn tags:
<cfgridcolumn name="artname" type="string_noCase"> <cfgridcolumn name="isSold" type="boolean"> <cfgridcolumn name="price" type="numeric"> <cfgridcolumn name="aDate" type="date">
Whats cool is that ColdFusion or ExtJS (I'm not sure which) is going to automatically try and convert these types from the data where possible. The grid looks like this:

A quick run through of the various types;
- string_noCase specifies that the column will be sorted without regards to case.
- The boolean type will show a checkbox, checked if the boolean is true. From this example you can see that it is smart enough to convert 0 and 1's into Boolean as well as true and false.
- The price column is set to numeric which limits the editing of the column to just numbers.
- Leaving the best for last is the date type which when editing displays a nice calendar option.

Overall some pretty cool additions that make the cfgrid tag more useful.
Here's the full code to generate the above:
<cfquery name="getArt" datasource="cfartgallery"> select ARTID, ARTNAME, DESCRIPTION, ISSOLD, PRICE, CURRENT_DATE aDate from ART </cfquery> <cfdump var="#getArt#" top="10"> <cfform> <cfgrid format="html" name="art" query="getArt" align="left" selectmode="edit"> <cfgridcolumn name="artname" type="string_noCase"> <cfgridcolumn name="isSold" type="boolean"> <cfgridcolumn name="price" type="numeric"> <cfgridcolumn name="aDate" type="date"> </cfgrid> </cfform>






Loading....