tablesorter help - sort by date wont work!
|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
tablesorter help - sort by date wont work!Hi I'm using www.tablesorter.com's implementation of a sort table, however it does not seem to recognize my client's preferred date format (10 November 2009).
Day Month Year - 10 November 2009 [CODE] $(document).ready(function() { $("#oldArticles").tablesorter( {sortList: [[0,1]]} ); }); [/CODE] It is sorting by day only.... all help is much appreciated! |
|
|
Re: tablesorter help - sort by date wont work!"it does not seem to recognize my client's preferred date format"
were you expecting it to? this will need a custom parser.... i can whip up an example, but it'll be a little bit before i could get to that On Nov 10, 11:14 am, sethwb <josepatt...@...> wrote: > Hi I'm usingwww.tablesorter.com'simplementation of a sort table, however it > does not seem to recognize my client's preferred date format (10 November > 2009). > > Day Month Year - 10 November 2009 > > [CODE] > $(document).ready(function() > { > $("#oldArticles").tablesorter( {sortList: [[0,1]]} );}); > > [/CODE] > > It is sorting by day only.... all help is much appreciated! > > -- > View this message in context:http://old.nabble.com/tablesorter-help---sort-by-date-wont-work%21-tp... > Sent from the jQuery General Discussion mailing list archive at Nabble.com. |
|
|
Re: tablesorter help - sort by date wont work!thank you very much MorningZ... Any kind of example would be great!
|
|
|
Re: tablesorter help - sort by date wont work!here you go:
http://jsbin.com/enata/edit Keep one major thought in mind with this awesome plugin: it's not very smart (it tries, but in the end, it can only account for so much)... it can sort numbers and strings... anything more complicated than that it needs direction :-) On Nov 10, 11:43 am, sethwb <josepatt...@...> wrote: > thank you very much MorningZ... Any kind of example would be great! > > -- > View this message in context:http://old.nabble.com/tablesorter-help---sort-by-date-wont-work%21-tp... > Sent from the jQuery General Discussion mailing list archive at Nabble.com. |
|
|
Re: tablesorter help - sort by date wont work!I've been trying to get this parser I've customized to work, but I'm not sure about the syntax... would this be easier to help me with/is this on the right track?
ts.addParser({ id: "shortDate", is: function(s) { return /\d{2,}[\s]\w{4,}[\s]\d{4,}/.test(s); }, format: function(s,table) { var c = table.config; s = s.replace(/\-/g," "); if(c.dateFormat == "us") { // reformat the string in ISO format s = s.replace(/(\d{2,})[\s](\w{4,})[\s](\d{4,})/, "$3/$1/$2"); } else if(c.dateFormat == "uk") { //reformat the string in ISO format s = s.replace(/(\d{2,0})[\s](\w{4,})[\s](\d{4,})/, "$3/$2/$1"); } else if(c.dateFormat == "dd/mm/yy" || c.dateFormat == "dd-mm-yy") { s = s.replace(/(\d{2,0})[\s](\w{4,})[\s](\d{4,})/, "$1/$2/$3"); } return $.tablesorter.formatFloat(new Date(s).getTime()); }, type: "numeric" }); |
|
|
Re: tablesorter help - sort by date wont work!Got an example of each date the value could be?
On Nov 10, 12:01 pm, sethwb <josepatt...@...> wrote: > I've been trying to get this parser I've customized to work, but I'm not sure > about the syntax... would this be easier to help me with/is this on the > right track? > > ts.addParser({ > id: "shortDate", > is: function(s) { > return /\d{2,}[\s]\w{4,}[\s]\d{4,}/.test(s); > }, > format: function(s,table) { > var c = table.config; > s = s.replace(/\-/g," "); > if(c.dateFormat == "us") { > // reformat the string in ISO format > s = s.replace(/(\d{2,})[\s](\w{4,})[\s](\d{4,})/, "$3/$1/$2"); > } else if(c.dateFormat == "uk") { > //reformat the string in ISO format > s = s.replace(/(\d{2,0})[\s](\w{4,})[\s](\d{4,})/, "$3/$2/$1"); > } else if(c.dateFormat == "dd/mm/yy" || c.dateFormat == "dd-mm-yy") { > s = s.replace(/(\d{2,0})[\s](\w{4,})[\s](\d{4,})/, "$1/$2/$3"); > } > return $.tablesorter.formatFloat(new Date(s).getTime()); > }, > type: "numeric" > }); > > -- > View this message in context:http://old.nabble.com/tablesorter-help---sort-by-date-wont-work%21-tp... > Sent from the jQuery General Discussion mailing list archive at Nabble.com. |
|
|
Re: tablesorter help - sort by date wont work!Nevermind - Just had a couple of syntax errors on the return. I would like to show my appreciation for your help somehow. If you ever need anything shoot me an email on here - I'm primarily a designer, in school for computer science.
cheers -seth |
| Free embeddable forum powered by Nabble | Forum Help |