Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

CFGRID date sort is not working in Coldfusion 9

Guest
Aug 09, 2010 Aug 09, 2010

<!--- 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?

2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 02, 2010 Sep 02, 2010

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 <><

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 02, 2010 Sep 02, 2010

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 03, 2010 Sep 03, 2010

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 <><

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 03, 2010 Sep 03, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 07, 2010 Sep 07, 2010

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 22, 2010 Sep 22, 2010

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 06, 2017 Feb 06, 2017
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources