Client sort using standardista-table-sorting JS

Posted on 2012-08-30
Medium Priority
Last Modified: 2012-10-01

I have the first column in my table as a display that COUNTS ROWS. I want the numbers always to be in numberic order 1, 2, 3, 4...  Even though I do not have a header for the column, when I click on the other headers, it keeps the number assigned to the row.

My code for the COUNTER is:
Dim counter
counter = 0

My code to display:
<td scope='row' width='25'>" & counter

I am attaching the STARDARDISTA code.
Question by:JLohman
  • 3
  • 2
LVL 25

Expert Comment

ID: 38354111
The standardista routine does not support the maintenance of an 'id' or 'sequence' ... when it sorts - it moves the entire row.

A work-around is is to maintain the sequence, and even generate it, via a separate JavaScript routine.  The attached file implements an example of this.  I coded it using jQuery.
LVL 25

Accepted Solution

Kyle Hamilton earned 2000 total points
ID: 38354143
the script you have sorts rows by storing the whole row as an item in an array, sorting the array, and re-rendering the rows from the array. So, the way it is written, you can't just "omit" a column.

What you could do is write script that replaces the content of those cells after the sorting has taken place. write it as a callback to the sorting function.

i'd be happy to oblige, if you could please supply a table with sample data.. :)

LVL 25

Expert Comment

by:Kyle Hamilton
ID: 38354347
If you want to maintain the row order, from 1 to whatever...

The following snippet will repopulate the row count column starting at 1. It assumes your row count column is the first column in the table.

add this around line 228, (right before the return statement)

function resetRowCount(table){
                    var rows = table.rows;
                    for (var i=1; i < table.rows.length; i++) {
                        rows[i].cells[0].innerHTML = i;

Open in new window

( By the way, your sorting script does not work in Chrome or FF )
LVL 25

Expert Comment

ID: 38354402
@kozaiwaniec - standardista is a routine available from http://www.workingwith.me.uk/articles/scripting/standardista_table_sorting.
I developed and tested my example using Chrome.  Did you include the common.js and css.js as well?

I would be wary of modifying the base routine unless a mechanism was implemented to turn on/off the 'row count' as other tables may be in use that do not require it - but still want to be sortable.
LVL 25

Expert Comment

by:Kyle Hamilton
ID: 38354440
oh ok. No, i did not have the other files. I thought this was a one off..

I'll have a look at the link.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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

750 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