Copy link to clipboard
Copied
<!--- using cfgridcolum type="date" --->
<cfset emps = querynew("firstname,department, salary,startdate")>
<cfset queryaddrow(emps,3)>
<cfset querysetcell(emps,"firstname","Debra",1)>
<cfset querysetcell(emps,"department","Accounting",1)>
<cfset querysetcell(emps,"salary","100000",1)>
<cfset querysetcell(emps,"startdate","2009/11/09",1)>
<cfset querysetcell(emps,"firstname","Doherty",2)>
<cfset querysetcell(emps,"department","Finance",2)><cfset querysetcell(emps,"salary","120000",2)><cfset querysetcell(emps,"startdate","2005/09/02",2)><cfset querysetcell(emps,"firstname","Ben",3)><cfset querysetcell(emps,"department","Law",3)><cfset querysetcell(emps,"salary","200000",3)><cfset querysetcell(emps,"startdate","2010/08/09",3)><cfform name="form01"> <cfgrid format="html" insert="yes" insertButton="Add Row" name="grid01" selectmode="edit" width=600 collapsible="true" title="Employees" autowidth="yes" query="emps" sort="yes" > <cfgridcolumn name="FirstName" header="FirstName"/> <cfgridcolumn name="Department" header="Department" /> <cfgridcolumn name="Salary" display=true header="Salary" type="numeric" values="1000000,1200000" valuesdisplay="1000000,1200000"/> <cfgridcolumn name="StartDate" display=true header="StartDate" type="date" mask="d/m/Y"/> </cfgrid></cfform>when i sort the grid column StartDate , it is doing to text sort instead of date sort, did anybody else face the same issue?
Copy link to clipboard
Copied
I'm having the same issue. The query is returning a field of type Date and the cfgridcolumn is set to type date but the grid sorts the data as a string.
Mark <><
Copy link to clipboard
Copied
It looks like CF is using the mask values to handle the sorting, if you try changing it to mask="Y/m/d" it would then sort correctly. Unfortunately it will not display to the user the way that you intended.
Copy link to clipboard
Copied
I'm still getting the same effect. I added a mask and the data still
sorts as if it is a string. Both date columns are Oracle date types.
<cfgridcolumn name="TASKNAME" header="Type" width="200">
<cfgridcolumn name="ORIG_StartDate" mask="Y/m/d" type="date" header="Start Date" width="200">
<cfgridcolumn name="ORIG_ENDDATE" mask="Y/m/d" type="date" header="End Date" width="200">
Mark <><
Copy link to clipboard
Copied
This BUG looks fixed in Coldfusion Update 9.0.1, that is what i did to resolve this issue.
http://www.adobe.com/support/coldfusion/downloads_updates.html#cf9
Copy link to clipboard
Copied
I'm having the same problem in Coldfusion 8, so it's not just limited to 9. Try to use the sort by clicking in the header, and it just starts sorting by months, completely disregarding year and day.
Copy link to clipboard
Copied
You can use html comment tags to put a sortable value first. i.e '<! -- 2010-12-31 -- > Dec 31, 2010'. you have to write it into your sql or use cfquerynew to do it.
Copy link to clipboard
Copied
Hi,
I have a cfgrid populated from a database .There are two date columns.When the user sorts the dates columns they are getting sorted as though they are in string format instead of date format.