0 Replies Latest reply on Jan 27, 2010 8:53 AM by stellarinterface

    headerRelease to sort by original order in the ResultEvent, not alphabetically or numerically

    stellarinterface

      I am using a ResultEvent to pull data from a remote cfc into a Flash datagrid component. One of the columns in my data grid is Date/Time, but it is formatted by 'DD-MON-YYYY HH24MI', and that is how my client wants to view date/time all over the application. As you can guess, this format is not sortable alpha-numerically. So, I've added a new field/colum to query (which I'm not displaying in the data grid), which formats in 'YYYY-MM-DD HH24MI', so that when it first appears in the data grid, it is sorted by date using this field in the correct fashion.


      I'm trying to create a function to create an exception for when the user clicks on the header for the date/time in the 'DD-MON-YYYY HH24MI' format, so that it uses the field for 'YYYY-MM-DD HH24MI' to sort instead. Problem is, I can't seem to find a way to sort by the original order the data came in (ORDER BY) via SQL, I only know how to use  sortItemsBy, which has the options of Array.DESCENDING, Array.CASEINSENSITIVE, Array.NUMERIC, Array.UNIQUESORT, Array.RETURNINDEXEDARRAY.


      If anyone can tell me how to sort by the original order the data came in as (using the ResultEvent from SQL/ColdFusion), instead of alphabetically or numerically, please let me know. Here is a sample of the function I'm using.

       

       

      /* FUNCTION TO SORT BY MAR_BIRTHDATESORT (col5, YYYY-MM-DD HH24MI) instead of MAR_BIRTHDATE (col3, DD-MON-YYYY HH24MI) */
      var dgSort_listener:Object = new Object();
      dgSort_listener.sortMode = Array.DESCENDING;
      dgSort_listener.headerRelease = function(eventObj:Object){
          var columnName:String = mars_dg.getColumnAt(eventObj.columnIndex).columnName ;
          if(columnName == 'MAR_BIRTHDATE'){
              var columnName:String = mars_dg.getColumnAt(5).columnName ;
              this.sortMode = (this.sortMode == Array.DESCENDING) ? 0 : Array.DESCENDING; // flip 
              mars_dg.sortItemsOn(columnName, mars_dg.getColumnAt(5));
          }
          else{
              this.sortMode = (this.sortMode == Array.DESCENDING) ? 0 : Array.DESCENDING; // flip
              mars_dg.sortItemsBy(columnName, eventObj.columnIndex | this.sortMode);
          }
      }
      mars_dg.addEventListener("headerRelease",
      dgSort_listener);