Link to home
Start Free TrialLog in
Avatar of JLohman
JLohman

asked on

Client sort using standardista-table-sorting JS

I am using the STANDARDISTA TABLE SORTING code.

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.
standardista-table-sorting-2.js
Avatar of Lee Wadwell
Lee Wadwell
Flag of Australia image

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.
Q-27848860.html
ASKER CERTIFIED SOLUTION
Avatar of Kyle Hamilton
Kyle Hamilton
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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;
                    }
                }
		resetRowCount(table);

Open in new window

( By the way, your sorting script does not work in Chrome or FF )
@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.
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.