setParser(1, function(v)
{
return Std.parseInt(StringTools.replace(v, ???,??™, ?????™));
});
var re = ~/\s(\d+)-(\d+)\s\(/;
sorter.setParser(2, function(v)
{
if(re.match(v))
return Std.parseInt(re.matched(1)) * 100 + Std.parseInt(re.matched(1));
else
return 0;
});
sorter.apply(js.Lib.document.getElementById(???countries???));
}
}
The apply() method first locates the table head, thead , and the table body, tbody , then adds an event
handler of the onclick method of each column heading; the event when triggered, executes
sortTable() function. This function receives the index of the column that is used to order the data. The
getData() function collects the data from the table on the first attempt of sorting. The function uses a first
invocation of getElementsByTagName() to retrieve all the rows, tr , in the table, and then for each row a
new invocation is used to retrieve the individual cells, td . To grab the content cell, the innerHTML
property is used. This property is also very useful to change the content of an element; the new value must
be a string containing a valid HTML fragment.
Pages:
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762