-
Notifications
You must be signed in to change notification settings - Fork 753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
emptyTo not working with custom parser #1278
Comments
Hi @aetna-wsa! The parser isn't returning an empty string, it is returning Try these changes: $.tablesorter.addParser({
id: 'pihmsDate',
is: function(s){
return false;
},
format: function(s){
var str = s.replace(/JAN/,01).replace(/FEB/,02).replace(/MAR/,03).replace(/APR/,04).replace(/MAY/,05).replace(/JUN/,06).replace(/JUL/,07).replace(/AUG/,08).replace(/SEP/,09).replace(/OCT/,10).replace(/NOV/,11).replace(/DEC/,12);
str = str.replace(/(\d{2})[\/\-](\d{1,2})[\/\-](\d{4})/, '$3/$2/$1');
var date = str ? new Date(str) : str;
return date instanceof Date && isFinite( date ) ? date.getTime() : s;
},
type: 'numeric'
}); Actually, I'm not sure why that parser is needed, at least for English named dates. I believe all modern browsers will correctly parse dates with the three letter month name:
|
Wow... I never considered that NaN was the value being returned. Nor did I know that three letter month names can be parsed as easily as any other date - I always found it to be an awkward format. Both these solutions work, but I'm going to go with shortDate, now, with the format of dd-mmm-yyyy I appreciate the help, Rob. Thank you! |
I am now using shortDate with the format described above. When I sort that column in either ascending or descending order, all empty cells stay at the bottom. Shouldn't the behavior reverse when moving from asc to desc (or vice versa)? |
The Edit: actually, that last demo is missing two newer settings: |
Perfect! The additions of |
I'm guessing this issue has been resolved, so I'm going to close it. If you continue to have problems, please feel free to continue the discussion in this thread. |
empty or emptyTo seem to be working correctly, but not if applied to a column with a unique parser. My parser is as follows, if that helps:
The text was updated successfully, but these errors were encountered: