Client sort using standardista-table-sorting JS

Posted on 2012-08-30
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
    LVL 25

    Expert Comment

    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

    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
    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

    @kozaiwaniec - standardista is a routine available from
    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
    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

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    "That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved." Ralph Waldo Emerson Introduction: One of the wonderful things about the web is that it makes it s…
    In my daily work (mainly using, I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
    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…

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now