ColdFusion grid formatting issues explained
Tags: Coldfusion
In a previous post I spoke how that in ColdFusion 9 that anything that was considered to be a date and had a time part to the string, ColdFusion 9 would actually strip the time and reformat the string to its custom rendering.
Since the release of ColdFusion 9.01 I again had a look into this problem, and although the time is no longer stripped from the string. Something else is very unexpected as a result to this new change.
This is something that one has to take into consideration when migrating over to ColdFusion 9 and you are using the cfgrid tag, to display data back to the user.
In the following images you can clearly see that the query is indeed returning the correct information on both counts, so we can eliminate any problems that may have been introduced into the cfquery tag.
Image from ColdFusion 8
Image from ColdFusion 9.01
When we then look at the data that is being displayed in the cfgrid itself we can see that there is a major difference in what its going on, in ColdFusion 8 it looks like the following image
And in ColdFusion 9.01 it looks like this.
Now before ColdFusion 9.01 was released as shown in my previous blog, the format of the string would always be a date and the time was always stripped from the string.
So why is this a problem for anyone to worry about, well if you want to get to the crunch of the problem there isn't really a major problem here and that is because Adobe have introduced a new attribute for HTML grids, to the column tag that allows you to format the data with a mask. But the hassle of going and changing code because the grid is no longer backward compatible is not something that I would really consider to be an acceptable practice either.
In other words I am saying that there was no care in what was changing here, and that shows in the 3 different versions that is being displayed. In ColdFusion 8 it was treated as a string and it was displayed as a string, and in ColdFusion 9.01 it now appears to be an actual JavaScript date object.
The upside to this is that in ColdFusion 9.01 is that we can now format this anyway we like using the mask grid column attribute, however I think that if you look at this from a different perspective Adobe may have not given this much thought either.
Why do I say that?
At the time of writing this mask attribute is not on the documentation that can be found on the Adobe docs website, so until that happens let me explain what Adobe have done. The attribute mask is now enabled for HTML grids as well, however if you read the notes on the changes it clearly indicates that the default behavior for formatting this is m/d/y.
However as you can see this was what was happening in ColdFusion 9.0, but in ColdFusion 9.01 it seems that this was reversed or something else is going wrong.
What would have been better?
First I can understand why this behavior has been introduced, however the default behavior of the grid output should have matched what is happening in ColdFusion 8. The reason behind this is because if you are like me and others, you may have already had added a custom renderer to render the date anyway and the data returned by ColdFusion 9/9.01 just breaks your application.
Now what I would have done is added a new attribute to the grid column tag, that was along the lines of cellRender. That allowed the user to provide a custom way to format any cell in the grid, as this is still a major let down for the current implementation of the cfgrid.
-
<p> Just to add one note - you say this is not documented anywhere. That is not true. It is documented in the new features guide for CF901. The online core reference is still for 900. In my opinion it should be updated.</p>
# Posted By Raymond Camden | 7/21/10 6:39 AM -
Ray,
That's correct the docs for ColdFusion 9, is what I was referring too. yes the changes are in the whats new and release notes for the updater. But must people will be going to the docs or what was known as livedocs first.
So the sooner that gets updated the better I think.
# Posted By Andrew Scott | 7/21/10 8:19 PM -
Andrew, Adobe's documentation for CF is terrible. I boggles my mind that they consistently do a poor job of documenting CF. Why can't Adobe do a decent job of documenting their products?
# Posted By "A CF User" | 8/8/11 11:18 AM -
"A CF User" - well, that's broad. ;) Have you left comments on the live docs system with the issues you have found? Just saying it is horrible really does disservice to the nearly 5k (may be even higher) pages of documentation out there. I use the docs every day and they are very helpful. Are they perfect? Heck no. But I've yet to find ANY technical docs out there that are. That's why it is important to use the commenting system to help us improve the docs.
p.s. Andy - your comments are now showing BR tags and other HTML things. I noticed in the email too.# Posted By Raymond Camden | 8/8/11 11:27 AM -
Ray, the bugs had been logged with Adobe and I was told by an engineer via email that these had been fixed and in regression testing.
To this day this has still not been released as a fix, so I am not sure what more you would like me to do here. Personally I am sick of all the bugs that are introduced and the list keeps growing, especially when these have all been reported months before the product was supposed to be released as well.
As for the comments, yeah I am aware of it and haven't fixed it as yet, mainly due to the fact that I have been working on a new and improved version of the application due soon.# Posted By Andrew Scott | 8/8/11 11:39 AM -
Andrew, I was _only_ commenting to CF User's comment about the bad docs, that's all.
# Posted By Raymond Camden | 8/8/11 11:42 AM -
Yeah sorry Ray, that was my bad... Need to go back and read the comments first, I didn't realise that "CF User" had posted something :-)
He is right though, but "CF User" I think Adobe even acknowledge that they are trying to do a better job here.# Posted By Andrew Scott | 8/8/11 11:46 AM



TweetBacks