Loading ...
Sorry, an error occurred while loading the content.

Re: [ydn-javascript] Re: datatable empty dates, invalid dates, NaNs

Expand Messages
  • Martin Tschofen
    Thank you for your quick response. Here s how I got it to work: Override the default date parser to attach a date in the past instead of null or invalid dates.
    Message 1 of 3 , Aug 22, 2008
    • 0 Attachment
      Thank you for your quick response.

      Here's how I got it to work:
      Override the default date parser to attach a date in the past instead of null or invalid dates. Thus old dates will sort to the bottom or top.

                  YAHOO.util.DataSource.parseDate = function(oData){
                      if(!(oData instanceof Date)){
                          var date = new Date(oData);
                          if(date == 'Invalid Date'){date = new Date('1/11/1900');}
                          return date;
                      } else {return oData;}
                  }
                 
      And then I created a custom formatter that wouldn't display these old dates.

              formatDate : function(elCell, oRecord, oColumn, oData) {
                  var d = new Date('1/11/1900');
                  if (oData > d) {
                      YAHOO.widget.DataTable.formatDate(elCell, oRecord, oColumn, oData);
                  } else {
                      elCell.innerHTML = '';
                  }
              },


      I did look at the custom sorting, but I have too many different date columns across a number of datatables to make it work efficiently.

      Do you see any problems with this approach?
      Thanks again for your help...martin
    Your message has been successfully submitted and would be delivered to recipients shortly.