Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

sorting arrow display

Posted on 2009-07-15
9
Medium Priority
?
460 Views
Last Modified: 2012-05-07
Hi,

I am using the table sorting code form this site "http://www.allmyscripts.com/Table_Sort/index.html#features".
Please see attachment gs-sortable.txt. for the code.
Its working fine, but i am having an issue with the display of my sorting indicator arrows.
When i sort the first time on the column AA i get my asc arrow. Fine, but when clicking on column BB to sort, the arrow image of column BB displays but the arrow image of column AA keeps displaying.
Please see attachment pic1.jpg
What i want is that, when i click on for example column BB to sort i don't want the arrow of my last sorting for example on column AA to keep displaying.
Please see attachment pic2.jpg

What code change must i do in the attachment "gs-sortable" in order to make only the selected column sorting arrow to display?

Please some code help. Thanks  

gs-sortable.txt
pic1.JPG
pic2.JPG
0
Comment
Question by:eaweb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 3

Expert Comment

by:SordSord
ID: 24863074
I think you want to change the code at line 297:

            obj.innerHTML = (icon.match(/</))? icon:
                  '<font color="' + TSort_Store.sort_colors[i] + '">' + icon + '</font>';

so that it only is processed if i equals 0

   if (i == 0) {
            obj.innerHTML = (icon.match(/</))? icon:
                  '<font color="' + TSort_Store.sort_colors[i] + '">' + icon + '</font>';
  }
0
 

Author Comment

by:eaweb
ID: 24863238
no, the arrow of column AA keep diplaying after sorting on column BB
0
 
LVL 3

Expert Comment

by:SordSord
ID: 24863565
Try adding an else case to clear the innerHTML value.

if (i == 0) {
  obj.innerHTML = (icon.match(/</))? icon:
                  '<font color="' + TSort_Store.sort_colors[i] + '">' + icon + '</font>';
} else {
  obj.innerHTML = '';
}

Open in new window

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:eaweb
ID: 24863885
Yes the arrow disappear, but another issue has come forward if I change the code as you say.
The issue is this:
if i click on column AA the first time to sort asc and then i want to sort asc on lets say on column BB the arrow disappear, but if I click 3 times on column BB asc, desc and the 3rd time to return to the original state, instead of going to the original state it goes to the asc state on column AA.

Is there a way to go to the original state after clicking the 3rd time on a column and not to the state of a previous column click?
0
 
LVL 3

Expert Comment

by:SordSord
ID: 24864229
Sure, insert the following line at line 232:

if (sort_keys.length > 1) sort_keys.length = 1;

(shown below in context)

This will keep resetting the array of sort keys back to length 1, so when you remove the current sort key, there won't be another to fall back to. Note that this will also change the behavior a bit as it will no longer be possible to sort on multiple columns.
      obj = document.getElementById ('TS_' + id + '_' + table_id);
      if	(obj != null)	obj.innerHTML = '';
    }
  }
 
if (sort_keys.length > 1) sort_keys.length = 1;
  var len = sort_keys.length;
  //	This will either remove the column completely from the sort_keys
  //	array (i = 0) or remove duplicate column number if present (i = 1).

Open in new window

0
 
LVL 3

Accepted Solution

by:
SordSord earned 2000 total points
ID: 24864272
Oh, even better, a few lines down is line 245:

if (len > 3)

change that to

if (len > 1)
0
 

Author Comment

by:eaweb
ID: 24868707
your good in javascript buddy.

i have posted another javascript question. can you help me with it? see link. i can't figure it out how to do it
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_24575360.html
0
 

Author Closing Comment

by:eaweb
ID: 31603734
great
0
 

Author Comment

by:eaweb
ID: 24868841
the solution of:

if (sort_keys.length > 1) sort_keys.length = 1;

did not work it keep display all the sorting arrows.
0

Featured Post

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.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

722 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