?
Solved

Client-side sort using STANDARDISTA-TABLE-SORTING.js

Posted on 2012-08-16
4
Medium Priority
?
600 Views
Last Modified: 2012-08-17
I am using the STANDARDISTA-TABLE-SORTING.js script.

I am having a problem with the sorting of number columns. If the columns include numbers all the same length (10, 31, 15, 20, 29), it sorts correctly. If the columns include numbers of varying lengths, it does not sort correctly. Some of the data is hard-code and the other data is generated from calculations of fields from the database. The following string is an example of an incorrect sort:
147,194
150,062
105,769
90,512
80,120
ILL.txt
0
Comment
Question by:JLohman
  • 2
  • 2
4 Comments
 
LVL 25

Expert Comment

by:lwadwell
ID: 38303618
Due to the comma in the number - it is sorting the values as text strings.

Are they $ amounts?  If so - putting a $ sign at the start (e.g. $147,194) and it will sort them properly.

If they are not $ amounts or you do not want a $ sign, then either remove the commas or a small change to the JavaScript file is required.

Which do you want?
0
 

Author Comment

by:JLohman
ID: 38304911
They are just numbers.

If the javascript is modified, will it continue to work with other reports?

I would prefer to be able to use commas.
0
 
LVL 25

Accepted Solution

by:
lwadwell earned 2000 total points
ID: 38304959
I know they are just numbers ... unfortunately the script was not programmed to recognise them as numbers.
The attached version was modified by me to recognise numbers with commas as currency actually (it removes the $ and , to sort as a number).
It should be fine with other reports, unless they also had numbers with commas - then their behaviour will change too ... for the better I would imagine.  BUT I have not extensively tested it NOR can I give any guarantees.
standardista-table-sorting.js
0
 

Author Closing Comment

by:JLohman
ID: 38306473
Works perfectly!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Recursive SQL is one of the most fascinating and powerful and yet dangerous feature offered in many modern databases today using a Common Table Expression (CTE) first introduced in the ANSI SQL 99 standard. The first implementations of CTE began ap…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question