Summary (^) ❘ 441
Summary
Using the $.tablesorter() plugin is an easy and straightforward experience of adding the plugin’s
code to your document and then enabling $.tablesorter() on whatever <table> elements you would
like to make sortable.You learned in this chapter that the out-of-the-box experience for sorting tables includes the ability
to sort one or more columns. To do this you need little more than the right HTML structure and
some CSS.You learned that the hot key for selecting multiple columns can be customized easily using the sort-
MultiSortKey option.You also learned that the various class names that $.tablesorter() uses for <th> elements can be
customized using the cssHeader, cssAsc, and cssDesc options.If you have a more complicated table and use markup in your table cells, you can control how text
is extracted from each cell for sorting using the textExtraction option. You can use the 'simple'
method, which just takes the content of the cell wholesale, regardless if it includes markup. You
can also use a callback function that specifi es explicitly how you’d like the text to be extracted. For
example, you could walk the DOM yourself and get the text node using JavaScript APIs directly,
instead of jQuery.Finally, the sortList option defi nes how a table should be sorted by default when the $.table-
sorter() plugin is applied.EXERCISES
- How is a table sorted by default?
- How would you use the Control key on a Mac or Windows keyboard as the key you press
when selecting a second column to sort?
- How would you customize the class names used on the
elements by the $.tablesorter()
plugin?