Sort Table on Multiple Columns

I have a dynamically generated table/contents that i want to give the user the ability to sort on multiple columns, columns will not always be beside each other

Rep Name (multiple occurrennces) Building ID (Multiple occurences per rep) Building Name  Employee Name Job code

theer can be any number of fields and the user can sort on multiple field

so i give teh user a group of drop downs that lets tehm selet up to 5 fields on which to sort, i then pass teh column indexes to a function and dynamucally sort on those selections....

how?

TIA
LVL 25
James RodgersWeb Applications DeveloperAsked:
Who is Participating?
 
ZvonkoSystems architectCommented:
I understand what you WANT, but I have the impression that you did not understood what I am trying to tell to you: you do overcomplicate the interface for an option that is USELESS in real life tables.
Look again at http://eeqp.com/stats/hof.html
Now sort two times for the 7th column labeled "Change".
If you do that sort after the page is loaded and no other sorting was before the two times Change sort, then you will see that zero points changers are sorted ascending in the third column: Pos/Ranking
Now sort for the first column "Experts" and sort again two times the "Change" column.
Now you see that first column is sorted in alphabetic ascending order for the zero changers. You see?
So my recommendation is to avoid overloading of user interface and sort in last order first way the columns that are relevant for final sorting result, in your case, sort first for Building and then for REP and you will get the table as you like it, sorted by REP and for same REPs sorted by Building number. You see?

0
 
ZvonkoSystems architectCommented:
The most people ask for multiple field sort without a moment to imagine when multiple fields sort makes sense.
My assumption is that all first four fields are unique, therefore you need NOT to sort for the first four fields when you also sort for the fifth field. Sort only the fifth field alone and you have the same sort order!

Your Rep, Building and Employee sorting is NOT a sorting but grouping. If you would sort for Employee names, then you can never maintain the building categories

Here a table sort example:
http://eeqp.com/stats/hof.html
The script behind the table is this:
http://eeqp.com/stats/zpSortHOF.js

The main part was designed by me and then extended by amebe, the QuickPost developer!
0
 
dbrittCommented:
See my old solution:

http:Q_21759382.html#16130456
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
James RodgersWeb Applications DeveloperAuthor Commented:
>>My assumption is that all first four fields are unique, therefore you need NOT to sort for the first four fields when you also sort for the fifth field. Sort only the fifth field alone and you have the same sort order!

would be true if the output could be sorted on the rep name when generated by the SQL, unfortunately, the source for all the data, other than the rep name, comes form an oracle server while the rep name is a local table on an SQL server and has to be matched up to the during the ouput loop, so i have base data sorted/ordered on the  building id which means teh rep info is not sequential
eg
REP                    Building         ............
Joe                     0036
Mike                   0099
steve                  0429
Joe                     0488
steve                  0489

so if the user want to see all of joes buildings together they need to sort it on joe, but at teh same time i would like to keep teh building order also so that it goes like
REP                    Building         ............
Joe                     0036
Joe                     0488
Mike                   0099
steve                  0429
steve                  0489

i did think this through, it's just that the way the data is gathered affects the final output, and needs to be sorted AFTER being displayed

0
 
dbrittCommented:
>> i did think this through, it's just that the way the data is gathered affects the final output, and needs to be sorted AFTER being displayed

But it doesn't seem like you tried my solution that I linked you to above. Try it out, it should take care of what you need.
0
 
ZvonkoSystems architectCommented:
Does not the EE ranking list sort like you ask for?
http://eeqp.com/stats/hof.html

0
 
ZvonkoSystems architectCommented:
Look at that table and click on name column header labeled "Expert"
You will see my name second last in that alpha sort order.
Click then on RegDate column and you will see I am in the first row.
All the time my ranking 15 stay in my row.

0
 
James RodgersWeb Applications DeveloperAuthor Commented:
yes, it is a sort, but i need it to sort on multiple columns
0
 
ZvonkoSystems architectCommented:
So you want the building numbers for Joes and Steves to be in ascending order in your upper example, right?

0
 
James RodgersWeb Applications DeveloperAuthor Commented:
Zvonko, yes, i want to be able to identify specific columne on which to sort,
so i wan the table to sort on REpP, BUILDING, and other field(s)

dbritt, i am looking at yours and it doesn't seem to be doing anything
0
 
dbrittCommented:
of course it does something, fill in some values and press "sort"...just use the multiSort function in the javascript for your table.
0
 
James RodgersWeb Applications DeveloperAuthor Commented:
gotcha!
0
 
ZvonkoSystems architectCommented:
:-)
0
 
ZvonkoSystems architectCommented:
Because the upper domain is no more accessible here the reference to the source on EE:
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_21425003.html

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.