A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Datagrid sort by number

Threaded View

  1. #4
    Senior Member
    Join Date
    Jan 2003
    Posts
    106
    Alright. Looks like we'll just have to figure it out on our own:


    Code:
    //custom sorting functions for the ranking column
    // replace "ColumnName" with the name of the column you want to sort
    // in this case, my column was located at columnIndex 2, adjust to suit your needs
    
    
    function sortNumericASC(a, b) {
      return Number(a.ColumnName) > Number(b.ColumnName);
    }
    function sortNumericDESC(a, b) {
      return Number(a.ColumnName) < Number(b.ColumnName);
    }
    var headerListener = new Object();
    headerListener.headerRelease = function(event){
      trace("column header num. "+event.columnIndex+" was pressed");
      if (event.columnIndex == 2){
        if(sortASC == NULL){
           sortASC = true;
        }else{
           sortASC = !sortASC;
        }
        if(sortASC){
           my_dg.sortItems(sortNumericASC);
        }else{
           my_dg.sortItems(sortNumericDESC);
        }
      }
    };
    my_dg.addEventListener("headerRelease", headerListener);
    Cheers,
    John
    Last edited by jvanv8; 08-16-2004 at 11:39 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center