Sorting with js tablesorter

Hi again,
I'm using  tablesorter for the first time and it's working pretty good but it is messing me up on dates and on empty cells .
I am trying to build some script to take the dates and rearrange it so it would be easier to sort
Instead of mm/dd/yyyy I am trying to parse it as yyyymmdd but it just isn't working

This is what I have for sorting but I have to admit I put this in because of the dates and empty cells not sorting but it has made no difference.
$(function () {
            $("table.tablesorter").tablesorter({
                widthFixed: false,
                sortList: [[0, 0]],
                headers: {
                    0: { sorter: false },
                    1: { sorter: false },
                    2: { sorter: false },
                    3: { sorter: "digit" },
                    4: { sorter: "text" },
                    5: { sorter: "text" },
                    6: { sorter: "text" },
                    7: { sorter: "text" },
                    8: { sorter: "text" },
                    9: { sorter: "myDateColumn" },
                    10: { sorter: "myDateColumn" },
                    11: { sorter: "myDateColumn" },
                    12: { sorter: "text" },
                    13: { sorter: "text" },
                    14: { sorter: "text" }
                }
            }) 
     });

Open in new window


and then I tried to do an addparse to try and do something with the date
  $.tablesorter.addparser({
            id: 'myDateColumn',
            is: function (s) {
                return false;
            },
            format: function (s) {
                var t = s.split("/");
                var newdate = t[2] + t[0] + t[1];
                return newdate;
            },
            type: 'numeric'

Open in new window


I thought this should work but it's not also there are some cells which are empty or actually they have " ----------"in them how can I work round these when trying to sort.
Any help is HIGHLY Appreciated
Niall GallagherDeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rainer JeschorCommented:
Hi,
please try this:
var newdate = parseInt('' + t[2] + '' + t[0] + '' + t[1]);

Open in new window


Otherwise please provide some sample data or try to repro on jsBin or jsFiddle.

Thanks and HTH
Rainer
Rainer JeschorCommented:
Sorry, one change to return a 0 if the string is empty / does not contain 2 slashes:
    $.tablesorter.addparser({
            id: 'myDateColumn',
            is: function (s) {
                return false;
            },
            format: function (s) {
                var t = s.split("/");
				if t.length == 3 {
					return parseInt(''+ t[2] + '' + t[0] + '' + t[1],10);
				} else {
					return 0;
				}
            },
            type: 'numeric'

Open in new window

If you want to sort the empty entries at the end, then return 99999999 instead of the 0.
HTH
Rainer
Niall GallagherDeveloperAuthor Commented:
Thank you Rainer for your help and it seems to make sense but there are 2 dates in the table which seem to stick together and are usually nearly half way down.
About 95% or more of the dates are in 2015 but there are 2 (one is 12/10/2014 and the other 02/12/2013) and they just keep showing up in the wrong places
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Niall GallagherDeveloperAuthor Commented:
How can I see if the parse is working
Rainer JeschorCommented:
Hi,
hm hard to say without the raw HTML source. Could you perhaps attach / paste the HTML source / data?
Perhaps its just a space / special character / inline HTML tags ...
Thanks.
Rainer
Rainer JeschorCommented:
The very best way would be to reproduce your situation e.g. at http://jsbin.com (and share the link inside this question).
Just take a sample of 4-8 rows from you existing set. Then we have something to work with and we can start to dig deeper into the current issue.
HTH
Rainer
Niall GallagherDeveloperAuthor Commented:
Thanks,
I have never used it before so don't hold your breath waiting. but again thanks for your help
Rainer JeschorCommented:
Hi,
you are welcome.
jsBin is nice in regards to have some kind of repro running on a web server, being able to reference scripts / plugins from CDN networks (HTTP and HTTPS) and share the issue with the world/experts - as most issues occur on private / internal sites where we experts have no access. This cannot solve every issue but in most cases some sample data is enough to get an idea how to solve / where the issue comes from.
As its late in Germany I will have a look tomorrow.
KR
Rainer
Niall GallagherDeveloperAuthor Commented:
Rainer,
Something I didn't mention yesterday, I built the table to be editable so its coming up in JSBin with a label and a textbox for each field but on the actual site , it has the label only until you click on it then the label disappears and the textbox becomes visible.
Thanks for your help and excuse the mess. Let me know what else you need or what I can do thanks

I'm not sure where to put the patch to the js files or the tablesorter file.

http://jsbin.com/yanulovuwu/1/edit?html,js,output
Niall GallagherDeveloperAuthor Commented:
Rainer,
I am searching to see why sorting is not working at all in JSBin.
I have tidied it up a lot since the last message but just can't figure out what I have forgot
Niall GallagherDeveloperAuthor Commented:
Niall GallagherDeveloperAuthor Commented:
Even in JSBin those 2 dates still show up in the wrong place look in App Date
RobOwner (Aidellio)Commented:
The issue here is that the plugin you're using hasn't been updated since 2008.  There is a bug in the plugin as there is nothing wrong with how you've normalised the parser.

I suggest moving to datatables https://www.datatables.net/examples/basic_init/table_sorting.html it is very well supported and developed.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Niall GallagherDeveloperAuthor Commented:
Thank you, and I will try it in the next few days and let you know how it goes.
Niall GallagherDeveloperAuthor Commented:
I have not put this into practice yet but I do believe it would be a better solution as while reading about tablesorter a lot of users seem to have the same problem as I do
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.