Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Sort Table on Multiple Columns

Posted on 2006-05-16
16
Medium Priority
?
13,228 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:James Rodgers
  • 7
  • 4
  • 3
14 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 16693796
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
 
LVL 15

Expert Comment

by:dbritt
ID: 16694513
See my old solution:

http:Q_21759382.html#16130456
0
 
LVL 25

Author Comment

by:James Rodgers
ID: 16698114
>>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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 15

Expert Comment

by:dbritt
ID: 16698329
>> 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
 
LVL 63

Expert Comment

by:Zvonko
ID: 16699297
Does not the EE ranking list sort like you ask for?
http://eeqp.com/stats/hof.html

0
 
LVL 63

Expert Comment

by:Zvonko
ID: 16699330
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
 
LVL 25

Author Comment

by:James Rodgers
ID: 16699478
yes, it is a sort, but i need it to sort on multiple columns
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 16699542
So you want the building numbers for Joes and Steves to be in ascending order in your upper example, right?

0
 
LVL 25

Author Comment

by:James Rodgers
ID: 16699595
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
 
LVL 15

Expert Comment

by:dbritt
ID: 16699790
of course it does something, fill in some values and press "sort"...just use the multiSort function in the javascript for your table.
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 2000 total points
ID: 16700163
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
 
LVL 25

Author Comment

by:James Rodgers
ID: 16700251
gotcha!
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 16700284
:-)
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 26528368
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
Suggested Courses

810 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