I am trying to create my own sort function for the table, allowing me to use a plugin on this Not my university's course.
Now I've got some javascript that will sort the table well:
var newDirection = 1; If ($ (this) .is ('sorted-asc')) {newDirection = -1; } Vari rows = $ table.find ('tbody & gt; tr'). () get receive; $ .short (rows, work (index, line) {row.sortKey = findSortKey ($). Child ('TD'). Eq (column));); Rows.sort (function (a, b) {if (a.sortKey & lt; b.sortKey) returns - new direction; if (a.sortKey> gt; b.sortKey) returns new; return 0;});
Sortable variables are those that are sorted by alpha or numeric.
Here, I will change the rows in the table in the correct order:
$ Each (lines, functions (index, line) {$ table.children ('tbody'). Attachment (line); row.sortKey = null;});
What would I like to do now, is there any way i can reverse the way? I do not mean that .reverse ()
will reverse the order of the table rows, but will actually sort the sort and put the values back to the way they were.
By default, the table command comes back by default if you want to make it.
Edit: It was my endeavor: I announced the variable only after declaring the rows:
var previous = $ Table.find ('tbody' tr '). Get ();
and then I tried to reorder it by the way it was set:
$ table.siblings ('a.reset' ). (Function () {$ .each (previous, function (index, line) {$ table.children ('tbody'). Attachment (line);});});
No comments:
Post a Comment