1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 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 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery tablesorter 2.0</title>
<!-- Demo stuff -->
<style>
#banner h1 em {color:#6cf;}
.main-nav {display:none;}
</style>
<link href="css/bootstrap-v4.min.css" rel="stylesheet">
<link href="css/jquery-ui.min.css" class="ui-theme" rel="stylesheet">
<link href="css/jq.css" rel="stylesheet">
<link href="css/menu.css" rel="stylesheet">
<link href="css/prettify.css" rel="stylesheet">
<link href="../css/theme.blue.css" rel="stylesheet">
</head>
<body id="root">
<input type="checkbox" class="main-nav-check" id="main-nav-check" />
<div class="main-nav" id="main-nav">
<div class="page-search">
<h2 class="title">table<em>sorter</em></h2>
<div class="input-group search-group">
<div class="status"></div>
<input type="text" placeholder="Find on page..." size="25" maxlength="25" class="search form-control input-sm">
<div class="input-group-btn">
<button type="button" class="search-clear btn btn-default tooltip-top" title="Clear search">
<span class="glyphicon glyphicon-remove"></span>
</button>
<button type="button" class="search-prev btn btn-default tooltip-top" title="Previous result">
<span class="glyphicon glyphicon-chevron-up"></span>
</button>
<button type="button" class="search-next btn btn-default tooltip-top" title="Next search">
<span class="glyphicon glyphicon-chevron-down"></span>
</button>
</div>
</div>
<div class="search-options input-group-btn">
<div class="switch">
<input type="radio" class="switch-input" name="view" value="Word" id="word" checked="checked">
<label for="word" class="switch-label switch-label-off tooltip-edge-left" title="Search for whole word only">Word</label>
<input type="radio" class="switch-input" name="view" value="letter" id="letter">
<label for="letter" class="switch-label switch-label-on tooltip-bottom" title="Search for letters">Letter</label>
<span class="switch-selection btn-primary"></span>
</div>
<div class="switch">
<input type="radio" class="switch-input" name="view2" value="Ab" id="cstrue">
<label for="cstrue" class="switch-label switch-label-off tooltip-bottom" title="Case-Sensitive search">Ab</label>
<input type="radio" class="switch-input" name="view2" value="aa" id="csfalse" checked="checked">
<label for="csfalse" class="switch-label switch-label-on tooltip-edge-right" title="Case-Insensitive search">ab</label>
<span class="switch-selection btn-primary"></span>
</div>
<a href="https://github.com/Mottie/tablesorter/wiki/Search" class="tooltip-right glyphicon glyphicon-question-sign" title="Get search instructions">
</a>
</div>
</div>
<div class="page-links">
<a href="#Introduction">Introduction</a>
<a href="#Demo">Demo</a>
<a href="#Getting-Started">Getting started</a>
<a href="#Examples">Examples</a>
<a href="#Configuration">Configuration</a>
<a href="#Widget-options">Widget & Pager Options</a>
<a href="#methods">Methods</a>
<a href="#events">Events</a>
<a href="#api">API</a>
<a href="#Download">Download</a>
<a href="#Compatibility">Compatibility</a>
<a href="#Support">Support</a>
<a href="#Credits">Credits</a>
</div>
</div>
<label for="main-nav-check" class="tooltip-right toggle-menu main-header" onclick="" title="Click to toggle the side menu">
<span></span>
</label>
<div id="main">
<div id="banner">
<h1>table<em>sorter</em> <small>(unofficial fork)</small></h1>
<h2>Documentation</h2>
<h3>Flexible client-side table sorting</h3>
</div>
<p>
<strong>Original Author:</strong> Christian Bach<br>
<strong>Maintainer of this fork:</strong> Rob Garrison (Mottie)<br>
<strong>Version:</strong> <a class="current-version" href="https://github.com/Mottie/tablesorter/archive/master.zip">2.1+</a> (<a href="https://github.com/Mottie/tablesorter/wiki/Changes">changelog</a>)
<iframe class="github-btn" src="https://ghbtns.com/github-btn.html?user=mottie&repo=tablesorter&type=fork&count=true" width="90" height="20" title="Fork on GitHub"></iframe>
<iframe class="github-btn" src="https://ghbtns.com/github-btn.html?user=mottie&repo=tablesorter&type=watch&count=true" width="100" height="20" title="Star on GitHub"></iframe>
<br>
<strong>Licence:</strong>
Dual licensed under <a class="external" href="http://www.opensource.org/licenses/mit-license.php">MIT</a>
or <a class="external" href="http://www.opensource.org/licenses/gpl-license.php">GPL</a> licenses (pick one).<br>
</p>
<a id="Contents"></a>
<h1>Contents</h1>
<ol>
<li><a href="#Introduction">Introduction</a></li>
<li><a href="#Demo">Demo</a></li>
<li><a href="#Getting-Started">Getting started</a></li>
<li><a href="#Examples">Examples</a></li>
<li><a href="#Configuration">Configuration</a></li>
<li><a href="#Widget-options">Widget & Pager Options</a> (v2.1)</li>
<li><a href="#methods">Methods</a></li>
<li><a href="#events">Events</a></li>
<li><a href="#api">API</a></li>
<li><a href="#Download">Download</a></li>
<li><a href="#Compatibility">Compatibility</a></li>
<li><a href="#Support">Support</a></li>
<li><a href="#Credits">Credits</a></li>
</ol>
<a id="Introduction"></a>
<h1>Introduction</h1>
<p>
tablesorter is a <a class="external" href="http://jquery.com">jQuery</a> plugin for turning a
standard HTML table with THEAD and TBODY tags into a sortable table without page refreshes.
tablesorter can successfully parse and sort many types of data including linked data in a cell.
It has many useful features including:
</p>
<ul>
<li>Multi-column sorting</li>
<li>Multi-tbody sorting - see the <a href="#options">options</a> table below</li>
<li>Parsers for sorting text, URIs, integers, currency, floats, IP addresses, dates (ISO, long and short formats), time. <a href="example-parsers.html">Add your own easily</a></li>
<li>Support secondary "hidden" sorting (e.g., maintain alphabetical sort when sorting on other criteria)</li>
<li>Extensibility via <a href="example-widgets.html">widget system</a></li>
<li>Cross-browser: IE 6.0+, FF 2+, Safari 2.0+, Opera 9.0+</li>
<li>Works with jQuery 1.2.6+ (jQuery 1.4.1+ needed with some widgets).</li>
<li>Works with jQuery 1.9+ ($.browser.msie was removed; needed in the original version).</li>
<li>Small code size</li>
</ul>
<a id="Demo"></a>
<h1>Demo</h1>
<table id="tablesorter-demo" class="tablesorter-blue">
<thead>
<tr>
<th>Account #</th>
<th>First Name</th>
<th>Last Name</th>
<th>Age</th>
<th>Total</th>
<th>Discount</th>
<th>Difference</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<tr>
<td>A42b</td>
<td>Peter</td>
<td>Parker</td>
<td>28</td>
<td>$9.99</td>
<td>20.9%</td>
<td>+12.1</td>
<td>Jul 6, 2006 8:14 AM</td>
</tr>
<tr>
<td>A255</td>
<td>Bruce</td>
<td>Jones</td>
<td>33</td>
<td>$13.19</td>
<td>25%</td>
<td>+12</td>
<td>Dec 10, 2002 5:14 AM</td>
</tr>
<tr>
<td>A33</td>
<td>Clark</td>
<td>Evans</td>
<td>18</td>
<td>$15.89</td>
<td>44%</td>
<td>-26</td>
<td>Jan 12, 2003 11:14 AM</td>
</tr>
<tr>
<td>A1</td>
<td>Bruce</td>
<td>Almighty</td>
<td>45</td>
<td>$153.19</td>
<td>44.7%</td>
<td>+77</td>
<td>Jan 18, 2001 9:12 AM</td>
</tr>
<tr>
<td>A102</td>
<td>Bruce</td>
<td>Evans</td>
<td>22</td>
<td>$13.19</td>
<td>11%</td>
<td>-100.9</td>
<td>Jan 18, 2007 9:12 AM</td>
</tr>
<tr>
<td>A42a</td>
<td>Bruce</td>
<td>Evans</td>
<td>22</td>
<td>$13.19</td>
<td>11%</td>
<td>0</td>
<td>Jan 18, 2007 9:12 AM</td>
</tr>
</tbody>
</table>
<p class="tip">
<span class="label label-info">TIP!</span> Sort multiple columns simultaneously by holding down the <kbd>Shift</kbd> key and clicking a second, third or even fourth column header!
</p>
<a id="Getting-Started"></a>
<h1>Getting started</h1>
<p>
To use the tablesorter plugin, include the <a class="external" href="http://jquery.com">jQuery</a>
library and the tablesorter plugin inside the <code><head></code> tag
of your HTML document:
</p>
<pre class="prettyprint lang-html"><!-- choose a theme file -->
<link rel="stylesheet" href="/path/to/theme.default.css">
<!-- load jQuery and tablesorter scripts -->
<script type="text/javascript" src="/path/to/jquery-latest.js"></script>
<script type="text/javascript" src="/path/to/jquery.tablesorter.js"></script>
<!-- tablesorter widgets (optional) -->
<script type="text/javascript" src="/path/to/jquery.tablesorter.widgets.js"></script>
</pre>
<p>tablesorter works on standard HTML tables. <strong>You must include THEAD and TBODY tags</strong>:</p>
<pre class="prettyprint lang-html"><table id="myTable" class="tablesorter">
<thead>
<tr>
<th>Last Name</th>
<th>First Name</th>
<th>Email</th>
<th>Due</th>
<th>Web Site</th>
</tr>
</thead>
<tbody>
<tr>
<td>Smith</td>
<td>John</td>
<td>jsmith@gmail.com</td>
<td>$50.00</td>
<td>http://www.jsmith.com</td>
</tr>
<tr>
<td>Bach</td>
<td>Frank</td>
<td>fbach@yahoo.com</td>
<td>$50.00</td>
<td>http://www.frank.com</td>
</tr>
<tr>
<td>Doe</td>
<td>Jason</td>
<td>jdoe@hotmail.com</td>
<td>$100.00</td>
<td>http://www.jdoe.com</td>
</tr>
<tr>
<td>Conway</td>
<td>Tim</td>
<td>tconway@earthlink.net</td>
<td>$50.00</td>
<td>http://www.timconway.com</td>
</tr>
</tbody>
</table></pre>
<p>Start by telling tablesorter to sort your table when the document is loaded:</p>
<pre class="prettyprint lang-js">$(function() {
$("#myTable").tablesorter();
});</pre>
<p>
Click on the headers and you'll see that your table is now sortable! You can
also pass in configuration options when you initialize the table. This tells
tablesorter to sort on the first and second column in ascending order.
</p>
<pre class="prettyprint lang-js">$(function() {
$("#myTable").tablesorter({ sortList: [[0,0], [1,0]] });
});</pre>
<p class="tip">
<span class="label label-info">NOTE!</span> tablesorter will auto-detect most data types including numbers, dates, ip-addresses for more information see <a href="#Examples">Examples</a>.
</p>
<a id="Examples"></a>
<h1>Examples</h1>
<p>
These examples will show what's possible with tablesorter. You need Javascript enabled to
run these samples, just like you and your users will need Javascript enabled to use tablesorter.
</p>
<div class="box">
<h3>Basic</h3>
<h4>Sorting</h4>
<ul>
<li>Initial:
<ul>
<li><a href="example-option-sort-list.html">Table sort</a> (<a href="#sortlist"><code>sortList</code></a>).</li>
<li>Sort direction (using <a href="#sortinitialorder"><code>sortInitialOrder</code></a> option [<a href="example-option-sort-order.html">demo</a>], or <a href="example-options-headers-order.html">other methods</a>).</li>
</ul>
</li>
<li>Prevent or reset a sort:
<ul>
<li><a href="example-option-sortreset-sortrestart.html">Using sortReset & sortRestart options</a> (<a href="#sortreset"><code>sortReset</code></a> & <a href="#sortrestart"><code>sortRestart</code></a>).</li>
<li><a href="example-method-sortreset.html">Resetting the entire table sort</a> (<a href="#sortreset-method"><code>sortReset</code></a> method; v2.4.7).</li>
<li><a href="example-options-headers-locked.html">Lock sort order</a>.</li>
<li><a href="example-options-headers.html">Disable sort for a column</a> (<span class="version updated">v2.18.1</span>).</li>
<li><a href="example-widget-column-selector.html">Disable sort for an entire row</a> (<a href="#cssignorerow"><code>cssIgnoreRow</code></a> class; v2.18.4).</li>
</ul>
</li>
<li>Modify a sort:
<ul>
<li><a href="example-option-sort-force.html">Force a default sorting order</a> (<a href="#sortforce"><code>sortForce</code></a>).</li>
<li><a href="example-option-sort-append.html">Append a sort to the selected sorting order</a> (<a href="#sortappend"><code>sortAppend</code></a>; <span class="version updated">v2.24.0</span>).</li>
<li><a href="example-option-sort-empty.html">Sorting empty cells</a> (<a href="#emptyto"><code>emptyTo</code></a>; v2.1.11).</li>
</ul>
</li>
<li>How to:
<ul>
<li><a href="example-option-selectorsort.html">Using selectorSort option</a> (<a href="#selectorsort"><code>selectorSort</code></a>; v2.4).</li>
<li><a href="example-option-sort-key.html">Change the default multi-sorting key</a> (<a href="#sortmultisortkey"><code>sortMultiSortKey</code></a>).</li>
<li><a href="example-option-custom-sort.html">Custom sort script</a> (<a href="#textsorter"><code>textSorter</code></a>; added v2.2; updated <span class="version updated">v2.12</span>).</li>
<li><a href="example-locale-sort.html">Sorting Accented Characters</a> (<a href="#sortlocalecompare"><code>sortLocaleCompare</code></a>; v2.24; <a href="https://github.com/Mottie/tablesorter/wiki/Language">languages</a>).</li>
<li><a href="example-trigger-sort.html">Sort table using a link outside the table</a> (external link; <span class="updated version">v2.17.0</span>).</li>
<li><a href="example-child-rows.html">Attach child rows (rows that sort with their parent row)</a> (<span class="updated version">v2.15.12</span>).</li>
<li><a href="example-child-rows-filtered.html">Use child rows + filter widget</a> (<span class="updated version">v2.22.0</span>).</li>
<li><a href="example-multiple-tbodies.html">Sorting with Multiple Tbodies</a> (v2.2).</li>
<li><a href="example-header-column-span.html">Sorting Across Multiple Columns</a> (v2.3).</li>
<li><a href="example-option-show-processing.html">Show a processing icon during sorting/filtering</a> (v2.4).</li>
<li><a href="example-option-delay-init.html">Delay table initialization</a> (<a href="#delayinit"><code>delayInit</code></a>).</li>
<li><a href="example-colspan.html">Sort & filter with colspans</a> (<a href="#duplicatecolspan"><code>duplicateSpan</code></a>; <span class="version">v2.25.0</span>).</li>
</ul>
</li>
</ul>
<h4>Theming</h4>
<ul>
<li>The <a href="example-option-theme-bootstrap-v2.html">Bootstrap v2.x</a>, <a href="example-option-theme-bootstrap-v3.html">Bootstrap v3.x</a> & <a href="example-widget-ui-theme.html">jQuery UI</a> themes require the uitheme widget.</li>
<li>The <a href="example-option-theme-bootstrap-v4.html">Bootstrap v4.x</a> theme (<span class="version">v2.28.4</span>; <span class="version updated">2.30.7</span>) does not require the uitheme widget!</li>
<li>Set up a <a href="example-option-theme-metro-style.html">Metro style theme</a> (<span class="version">v2.16.4</span>).</li>
<li>Set up a <a href="example-option-theme-materialize.html">Materialize theme</a> (<span class="version">v2.27.0</span>; <span class="version updated">v2.30.7</span>).</li>
<li>Use css to <a href="example-css-highlighting.html">highlight rows & columns</a> (<span class="version">v2.20.0</span>); css file added (<span class="version">v2.28.6</span>).</li>
<li>See all <a href="themes.html">available themes</a> (<span class="version updated">v2.30.7</span>).</li>
</ul>
<p></p>
<h4>Using Parsers / Extracting Content</h4>
<ul>
<li><a href="example-option-built-in-parsers.html">Built-in parsers</a>(full list)</li>
<li><a href="example-option-digits.html">Dealing with digits!</a></li>
<li><a href="example-options-headers-digits-strings.html">Dealing with text strings in numerical sorts</a> (<a href="#stringto"><code>stringTo</code></a>; v2.0.10).</li>
<li><a href="example-parsers-class-name.html">Disable sorting or set the column parser using class names</a> (v2.0.11).</li>
<li><a href="example-parsers-jquery-data.html">Disable sorting or set the column parser using data</a> (v2.3).</li>
<li><a href="example-options-headers-parser.html">Disable parsing of column content</a> (<span class="version">v2.17.1</span>).</li>
<li><a href="example-extractors-parsers.html">Using extractors with parsers</a> (<span class="version">v2.17.6</span>).</li>
<li><a href="example-option-date-format.html">Changing the date format</a> (v2.0.23).</li>
</ul>
<br/>
<h3>Advanced</h3>
<h4>Parsers / Extracting Content</h4>
<ul>
<li><a href="example-parsers.html">Parser, writing your own</a> (<a href="#function-addparser"><code>addParser</code></a>; <span class="updated version">v2.18.0</span>; <span class="version updated">v2.18.0</span>).</li>
<li><a href="example-parsers-advanced.html">Parser, writing your own, advanced use</a> (v2.1; <span class="updated version">v2.18.0</span>).</li>
<li><a href="example-option-text-extraction.html">Dealing with markup inside cells</a> (<a href="#textextraction"><code>textExtraction</code></a> function).</li>
<li><a href="example-options-headers-parser.html">Skip the parsing of column content</a> (<span class="version">v2.17.1</span>).</li>
</ul>
<h4>Widgets / Plugins</h4>
<ul>
<li><a href="example-apply-widget.html">Applying widgets</a></li>
<li><a href="example-widgets.html">Widgets, writing your own</a> (<a href="#function-addwidget"><code>addWidget</code></a>).</li>
<li><a href="example-pager-ajax.html">Pager plugin - ajax</a> (v2.1; <span class="version updated">v2.18.0</span>).</li>
<li><a href="example-pager-filtered.html">Pager plugin + filter widget</a> (v2.4).</li>
</ul>
<h4>Adding / Removing Content</h4>
<ul>
<li><a href="example-empty-table.html">Initializing tablesorter on a empty table</a>.</li>
<li><a href="example-ajax.html">Appending table data with ajax</a> (<a href="#update"><code>update</code></a>).</li>
<li><a href="example-add-rows.html">Adding a table row</a> (<a href="#addrows"><code>addRows</code></a>; v2.0.16).</li>
<li><a href="example-update-all.html">Update an entire table column (<code>thead</code> and <code>tbody</code>)</a> (<a href="#updateall"><code>updateAll</code></a>; <span class="version">v2.8</span>).</li>
<li><a href="example-update-cell.html">Update the table after cell content has changed</a> (<a href="#updatecell"><code>updateCell</code></a>).</li>
<li><a href="example-pager.html">Pager plugin</a> - examples of how to add and remove rows.</li>
</ul>
<h4>Change Header Style</h4>
<ul>
<li><a href="example-widget-ui-theme.html">UITheme widget</a> (v2.0.9; <span class="version updated">v2.27.0</span>).</li>
<li><a href="example-option-render-header.html">Modifying the Header during rendering</a> (<a href="#onrenderheader"><code>onRenderHeader</code></a>).</li>
<li><a href="example-option-render-template.html">Modifying the Header using a template</a> (<a href="#headertemplate"><code>headerTemplate</code></a>; v2.7).</li>
</ul>
<br/>
<h3>Other</h3>
<h4>Options & Events</h4>
<ul>
<li><a href="example-triggers.html">Triggers sortEnd and sortStart (Displaying sorting progress)</a>.</li>
<li><a href="example-extending-defaults.html">Extending default options</a>.</li>
<li><a href="example-option-debug.html">Enabling debug mode</a> (<a href="#debug"><code>debug</code></a>).</li>
</ul>
<h4 id="metadata">Metadata - setting inline options</h4>
<ul>
<li>*Note* you can use class names (version 2.0.11+, <a href="example-parsers-class-name.html">demo</a>), or jQuery data (version 2.3+, <a href="example-parsers-jquery-data.html">demo</a>) instead of meta data.</li>
<li><a href="example-meta-sort-list.html">Set a initial sorting order using metadata</a>.</li>
<li><a href="example-meta-headers.html">Disable header using metadata</a>.</li>
<li><a href="example-meta-parsers.html">Setting column parser using metadata</a>.</li>
</ul>
</div>
<div class="box">
<h3 id="demos">Demos</h3>
<h4>Playgrounds & Other demos</h4>
<ul>
<li><a href="http://jsfiddle.net/Mottie/bbxxomhx/">tablesorter basic demo</a> (includes widgets).</li>
<li><a href="http://jsfiddle.net/Mottie/dn1r0cy7/">tablesorter basic demo using jQuery UI theme</a>.</li>
<li><a href="http://jsfiddle.net/Mottie/wty134u7/">tablesorter basic demo with pager plugin</a>.</li>
<li>LESS themes (modify the colors in these demos dynamically):
<ul>
<li><a href="http://codepen.io/Mottie/pen/eqBbn">tablesorter LESS theme</a>.</li>
<li><a href="http://codepen.io/Mottie/pen/Ltzpi">tablesorter Bootstrap LESS theme</a> (<span class="version">v2.16.4</span>).</li>
<li><a href="http://codepen.io/Mottie/pen/gCslk">tablesorter Metro LESS theme</a> (<span class="version">v2.16.4</span>).</li>
<li><a href="http://codepen.io/Mottie/pen/LbXdNR">tablesorter SCSS theme</a> (<span class="version">v2.28.2</span>).</li>
</ul>
</li>
<li>Check out the <a href="https://github.com/Mottie/tablesorter/wiki">home wiki page</a> <span class="label label-info">more demos</span>!</li>
</ul>
<h4 id="extras">Plugins / Widgets<br>
<span class="xsmall"><span class="results">†</span> these widgets are included in the <code>jquery.tablesorter.widgets.js</code> file (except for extra filter formatter functions).</span>
<br>
<span class="xsmall"><span class="results">‡</span> this widget is included with the plugin core.</span>
</h4>
<ul>
<li><a href="example-widget-align-character.html">Align Character Widget</a> (<span class="version">v2.15.8</span>; <span class="version updated">v2.19.0</span>).</li>
<li><a href="example-widget-build-table.html">Build table Widget</a> (<span class="version">v2.11</span>; <span class="version updated">v2.30.0</span>).</li>
<li><span class="label label-info">Beta</span> <a href="example-widget-chart.html">Chart Widget</a> (<span class="version">v2.19.0</span>; <span class="version updated">v2.24.0</span>).</li>
<li><span class="results">†</span> <a href="example-widget-columns.html">Columns highlight widget</a> (v2.0.17; <span class="version updated">v2.28.11</span>).</li>
<li><a href="example-widget-column-selector.html">Column selector widget</a> (<span class="version">v2.15</span>; <span class="version updated">v2.30.0</span>).</li>
<li><a href="example-widget-editable.html">Content editable widget</a> (v2.9; <span class="version updated">v2.31.0</span>).</li>
<li><a href="example-widget-current-sort.html">Current Sort Widget</a> (<span class="version">v2.27.0</span>).</li>
<li><span class="label label-info">Beta</span> <a href="example-dragtable.html">Dragtable mod</a> - (jQuery UI widget for column reordering [<a class="external" href="http://stackoverflow.com/a/27770224/145346">ref</a>]; <span class="version">v2.24.0</span>).</li>
<li><span class="results">†</span> Filter widget (<span class="version updated">v2.29.4</span>):
<ul>
<li><a href="example-widget-filter.html">basic</a> (v2.0.18; <span class="version updated">v2.30.0</span>).</li>
<li><a href="example-widget-filter-any-match.html">external option (match any column)</a> (<span class="version">v2.13.3</span>; <span class="version updated">v2.27.5</span>).</li>
<li><a href="example-widget-filter-external-inputs.html">external inputs</a> (<span class="version">v2.14</span>; <span class="version updated">v2.18.0</span>).</li>
<li><a href="example-widget-filter-custom.html">custom filter functions</a> (v2.3.6; <span class="version updated">v2.22.0</span>).</li>
<li><a href="example-widget-filter-custom-search.html">custom search types</a> (<span class="version">v2.17.5</span>; <span class="version updated">v2.27.0</span>).</li>
<li><a href="example-widget-filter-custom-search2.html">custom search type (example #2: date range)</a> (<span class="version">v2.19.1</span>; <span class="version updated">v2.24.6</span>).</li>
<li><a href="example-widget-filter-childrows.html">child rows</a> (<span class="version">v2.23.4</span>).</li>
<li>formatter: <a href="example-widget-filter-formatter-1.html">jQuery UI widgets</a> and <a href="example-widget-filter-formatter-2.html">HTML5 Elements</a> (v2.7.7; <span class="version updated">v2.17.5</span>).</li>
<li>formatter: <a href="example-widget-filter-formatter-select2.html">select2 v3</a> (<span class="version">v2.16.0</span>; <span class="version updated">v2.29.4</span>).</li>
<li>formatter: select2 v4 (TO DO)</li>
<li><a href="example-widget-filter-selectmenu.html">Using jQuery UI Selectmenu</a> (<span class="version">v2.24.4</span>; <span class="version updated">v2.28.12</span>).</li>
</ul>
</li>
<li><span class="label label-info">Beta</span> <a href="example-widget-formatter.html">Formatter widget</a> (<span class="version">v2.19.1</span>).</li>
<li>Grouping rows widget:
<ul>
<li><a href="example-widget-grouping.html">basic</a> (v2.8; <span class="version updated">v2.29.0</span>).</li>
<li><a href="example-widget-grouping-filter-childrows.html">Grouping + filter + child rows</a> (<span class="updated version">v2.28.0</span>).</li>
</ul>
</li>
<li><a href="example-widget-header-titles.html">Header titles widget</a> (v2.15.6; <span class="version updated">v2.24.4</span>).</li>
<li><span class="label label-info">Beta</span> <a href="example-widget-lazyload.html">Lazyload widget</a> (<span class="version">v2.24.0</span>; <span class="version updated">v2.25.7</span>).</li>
<li><a href="example-widget-mark.html">Mark widget</a> (<span class="version">v2.27.6</span>).</li>
<li><a href="example-widget-math.html">Math widget</a> (<span class="version">v2.16</span>; <span class="version updated">v2.31.1</span>).</li>
<li>
<a href="example-widget-output.html">Output widget</a> (<span class="version">v2.16</span>; <span class="version updated">v2.29.0</span>).
<br><br>
</li>
<li>Pager plugin (<a href="example-pager.html">basic</a> & <a href="example-pager-ajax.html">ajax</a> demos; <span class="version updated">v2.31.0</span>).</li>
<li>
Pager widget (<a href="example-widget-pager.html">basic</a> & <a href="example-widget-pager-ajax.html">ajax</a> demos) (<span class="version">v2.12</span>; <span class="version updated">v2.31.0</span>).<br>
<br>
</li>
<li><a href="example-widget-print.html">Print widget</a> (<span class="version">v2.16.4</span>; <span class="version updated">v2.25.8</span>).</li>
<li><a href="example-widget-reflow.html">Reflow widget</a> (<span class="version">v2.16</span>; <span class="version updated">v2.19.0</span>).</li>
<li><a href="example-widgets.html">Repeat headers widget</a> (v2.0.5; <span class="version updated">v2.19.0</span>).</li>
<li><span class="results">†</span> <a href="example-widget-resizable.html">Resizable columns widget</a> (v2.0.23.1; <span class="version updated">v2.29.2</span>).</li>
<li><span class="results">†</span> <a href="example-widget-savesort.html">Save sort widget</a> (v2.0.27; <span class="version updated">v2.30.1</span>).</li>
<li><a href="example-widget-scroller.html">Scroller widget</a> (<span class="version">v2.9</span>; <span class="version updated">v2.29.2</span>).</li>
<li><span class="label label-info">Beta</span> <a href="example-widget-sort-to-hash.html">Sort-to-hash widget</a> (<span class="version">v2.22.4</span>; <span class="version updated">v2.29.0</span>).</li>
<li><span class="label label-info">Beta</span> <a href="example-widget-sort-tbodies.html">Sort tbodies widget</a> (<span class="version">v2.22.2</span>; <span class="version updated">v2.28.0</span>).</li>
<li><a href="example-widget-static-row.html">Static row widget</a> (<span class="version">v2.16</span>; <span class="version updated">v2.24.0</span>).</li>
<li><span class="results">†</span> <a href="example-widget-sticky-header.html">Sticky header widget</a> (v2.0.21.1; <span class="version updated">v2.29.0</span>).</li>
<li><a href="example-widget-css-sticky-header.html">Sticky header (css3) widget</a> (<span class="version">v2.14.2</span>; <span class="version updated">v2.30.6</span>).</li>
<li><span class="results">†</span> <a href="#function-storage">Storage Widget</a> (<span class="version">v2.20.0</span>; <span class="version updated">v2.30.0</span>).</li>
<li><span class="label label-info">Beta</span> <a href="example-widget-toggle-tablesorter.html">Toggle Sort & Filter Widget</a> (<span class="version">v2.24.4</span>).</li>
<li><span class="results">†</span> UITheme widget (<span class="version">v2.0.9</span>; <span class="version updated">v2.30.0</span>):
<ul>
<li><a href="example-widget-ui-theme.html">jQuery UI theme</a> (v2.0.9; <span class="version updated">v2.27.0</span>).</li>
<li><a href="example-option-theme-bootstrap-v2.html">Bootstrap v2.x</a> (demo added <span class="version">v2.22.0</span>).</li>
<li><a href="example-option-theme-bootstrap-v3.html">Bootstrap v3.x</a> (v2.4.0; <span class="version updated">v2.28.4</span>).</li>
<li><a href="example-option-theme-bootstrap-v4.html">Bootstrap v4.x</a> (<span class="version updated">v2.29.3</span>) <span class="label warning">NOTE</span> <strong>does not</strong> require the uitheme widget!</li>
</ul>
</li>
<li><span class="label label-info">Beta</span> <a href="example-widget-vertical-group.html">Vertical Group Widget</a> (<span class="version">v2.29.2</span>).</li>
<li><span class="label label-info">Beta</span> <a href="example-widget-view.html">View Widget</a> (<span class="version">v2.24.0</span>; <span class="version updated">v2.26.6</span>).</li>
<li><span class="results">‡</span> <a href="example-widget-zebra.html">Zebra stripe widget</a>.</li>
</ul>
<h4 id="custom-parsers">Custom Parsers</h4>
<ul>
<li><a href="example-parsers-duration.html">Countdown parser</a> (<span class="version">v2.19.0</span>).</li>
<li><a href="example-parsers-dates.html">Date parsers</a> (<span class="version">v2.8</span>; <span class="version updated">v2.28.11</span>; includes weekday, month, two-digit year & <a class="external" href="https://sugarjs.com/docs/#/DateParsing">sugar.js</a> date parsers; a <a class="external" href="http://www.datejs.com/">datejs</a> parser is also available).</li>
<li><a href="example-parsers-date-range.html">Date range parsers</a> (<span class="version">v2.21.0</span>; <span class="version updated">v2.25.0</span>); if filters, include the <a href="example-widget-filter-custom-search2.html">insideRange</a> filter search type.</li>
<li><a href="example-parsers-duration.html">Duration parser</a> (<span class="version">v2.17.8</span>).</li>
<li><a href="example-parsers-feet-inch-fraction.html">Feet-inch-fraction parser</a> (<span class="version">v2.8</span>).</li>
<li><a href="example-parsers-file-type.html">File type & extension parsers</a> (<span class="version">v2.13</span>; <span class="version updated">v2.24.4</span>).</li>
<li><a href="example-parsers-named-numbers.html">Huge Numbers parser</a> (<span class="version">v2.25.5</span>).</li>
<li><a href="example-parsers-ignore-articles.html">Ignore leading articles parser</a> (Ignore "A", "An" and "The" in titles) (<span class="version">v2.8</span>).</li>
<li><a href="example-widget-grouping.html">Input/select parsers</a> (used by Grouping rows widget) (<span class="version">v2.8</span>; <span class="version updated">v2.30.7</span>).</li>
<li><a href="example-parsers-globalize.html">jQuery Globalize</a> (number & date parsers; <span class="version">v2.22.0</span>; <span class="version updated">v2.25.0</span>).</li>
<li><a href="example-parsers-leading-zeros.html">Leading zeros parser</a> (<span class="version">v2.28.6</span>).</li>
<li><a href="example-parsers-metric.html">Metric parser</a> (<span class="version">v2.8</span>).</li>
<li><a href="example-parsers-named-numbers.html">Named Numbers parser</a> (<span class="version">v2.18.0</span>; <span class="version updated">v2.22.0</span>).</li>
<li><a href="example-parsers-ip-address.html">Network (IPv4, IPv6 and MAC address parser</a> (<span class="version">v2.12</span>; <span class="version updated">v2.29.3</span>; <span class="label warning">NOTE</span> "ipAddress" parser moved to this file in v2.18.0).</li>
<li><a href="example-parsers-roman.html">Roman Numeral parser</a> (<span class="version">v2.17.3</span>).</li>
<li><a href="example-option-textsorter-semver.html">Semantic Versioning (Semver) sorting</a> (<span class="version">v2.14.3</span>; <span class="version updated">v2.21.4</span>).</li>
</ul>
<h4>Work-in-progress</h4>
<ul>
<li><span class="label label-info">Beta</span> <a href="../beta-testing/example-pager-custom-controls.html">Custom pager control script</a> (<span class="version updated">v2.27.8</span>).</li>
<li><span class="label label-info">Alpha</span> <a href="../beta-testing/example-widget-column-reorder.html">Column reorder widget</a> - not working 100% with sticky headers.</li>
<li><span class="label label-info">Alpha</span> Column reorder using the <a class="external" href="http://stackoverflow.com/a/27770224/145346">dragtable widget</a> (non-mod version).</li>
</ul>
</div>
<br class="clear">
<a id="Configuration"></a>
<h1>Configuration</h1>
<div class="tip">
<p></p>
tablesorter has many options you can pass in at initialization to achieve different effects<br>
<span class="label label-info">TIP!</span> Click on the link in the property column to reveal full details (or <a href="#" class="toggleAll">toggle</a>|<a href="#" class="showAll">show</a>|<a href="#" class="hideAll">hide</a> all) or double click to update the browser location.
</div>
<table id="options" class="tablesorter-blue options" data-sortlist="[[0,0]]">
<thead>
<tr>
<th class="property">Property</th>
<th class="type">Type</th>
<th class="defaults">Default</th>
<th class="descrip sorter-false">Description</th>
<th class="examples sorter-false">Link</th>
</tr>
</thead>
<tfoot>
<tr>
<th class="property">Property</th>
<th class="type">Type</th>
<th class="defaults">Default</th>
<th class="descrip">Description</th>
<th class="examples">Link</th>
</tr>
</tfoot>
<tbody>
<tr id="cancelselection">
<td><span class="permalink">cancelSelection</span></td>
<td>Boolean</td>
<td>true</td>
<td>Indicates if tablesorter should disable selection of text in the table header (TH). Makes header behave more like a button.</td>
<td></td>
</tr>
<tr id="duplicatespan">
<td><a href="#" class="permalink">duplicateSpan</a></td>
<td>Boolean</td>
<td>true</td>
<td>Any <code>colspan</code> cells in the tbody may have its content duplicated in the cache for each spanned column (<span class="version">v2.25.0</span>; <span class="version updated">v2.25.8</span>).
<div class="collapsible">
<p>If <code>true</code>, the cache will contain duplicated cell contents for every column the <code>colspan</code> includes. This makes it easier to sort & filter columns because a cell spanning all columns will only work with one parser.</p>
<p>In <span class="version updated">v2.25.8</span>, the contents of cells that are spanned will be set to an empty string only if the <code>textExtraction</code> setting is left as a string. If a function is added, it will be used to attempt to extract other content from the spanned cell (see <a href="http://jsfiddle.net/Mottie/aoLgu7f9/18/">demo</a> for an example).</p>
<pre class="prettyprint lang-js">// this row: <tr><td colspan="3">foo</td><td>bar</td></tr> results in this row cache:
[ 'foo', 'foo', 'foo', 'bar' ] // if duplicateSpan = true
[ 'foo', '', '', 'bar' ] // if duplicateSpan = false (no textExtraction function)</pre>
<span class="label warning">*NOTE*</span>
<ul>
<li>Cells in the tbody with a <code>rowspan</code> are <em>not yet supported</em> and will not sort or filter as you would expect.</li>
<li>Having these values in the cache does not automatically guarantee that all widgets will work as expected with <code>colspan</code>s in the tbody (e.g. scroller widget with fixed columns)</li>
</ul>
</div>
</td>
<td><a href="example-colspan.html">Example</a></td>
</tr>
<tr id="cssasc">
<td><a href="#" class="permalink">cssAsc</a></td>
<td>String</td>
<td>""</td>
<td>Additional CSS class applied to style the header with a ascending sort (<span class="version updated">v2.11</span>).
<div class="collapsible"><br>
Changed to empty string (<code>""</code>) in v2.11, as the <code>"tablesorter-headerAsc"</code> class will always be added to a header cell with an ascending sort; this option now contains any additional class names to add.
<p>Example from the blue theme:</p>
<pre class="prettyprint lang-css">.tablesorter-blue .tablesorter-headerAsc {
background-color: #9fbfdf;
background-image: url(black-asc.gif);
}</pre>
Default changed v2.5 to <code>"tablesorter-headerAsc"</code>. Default changed v2.1.7 to <code>"tablesorter-headerSortUp"</code>. Original default: <code>"headerSortUp"</code></div>
</td>
<td></td>
</tr>
<tr id="csschildrow">
<td><a class="toggle" href="#">cssChildRow</a></td>
<td>String</td>
<td>"tablesorter-childRow"</td>
<td>Add this css class to a child row that should always be attached to its parent. Click on the "cssChildRow" link to toggle the view on the attached child row. Previous default was <code>"expand-child"</code> (Modified v2.4).</td>
<td>
<a href="example-child-rows.html">1</a>
<a href="example-child-rows-filtered.html">2</a>
</td>
</tr>
<tr class="tablesorter-childRow">
<td></td>
<td></td>
<td></td>
<td>This is an entirely new row, but attached to the row above while sorting<br>
cssChildRow Example HTML:
<pre class="prettyprint lang-html"><table width="100%" border="1">
<thead>
<tr>
<th>Item #</th>
<th>Name</th>
<th>Available</th>
</tr>
</thead>
<tbody>
<tr>
<td>12345</td>
<td>Toy Car</td>
<td>5</td>
</tr>
<tr class="tablesorter-childRow"> <!-- this row will remain attached to the above row, and not sort separately -->
<td colspan="3">
It's a toy car!
</td>
</tr>
<tr>
<td>23456</td>
<td>Toy Plane</td>
<td>2</td>
</tr>
<tr class="tablesorter-childRow"> <!-- this row will remain attached to the above row, and not sort separately -->
<td colspan="3">
It's a toy plane!
</td>
</tr>
<tr class="tablesorter-childRow"> <!-- this row will remain attached to the above two rows, and not sort separately -->
<td colspan="3">
and it flies!
</td>
</tr>
</tbody>
</table></pre>
</td>
<td></td>
</tr>
<tr id="cssdesc">
<td><a href="#" class="permalink">cssDesc</a></td>
<td>String</td>
<td>""</td>
<td>Additional CSS class applied to style the header with a descending sort (<span class="version updated">v2.11</span>).
<div class="collapsible"><br>
Changed to empty string in v2.11, as the <code>"tablesorter-headerDesc"</code> class will always be added to a header cell with a descending sort; this option now contains any additional class names to add.
<p>Example from the blue theme:</p>
<pre class="prettyprint lang-css">.tablesorter-blue .tablesorter-headerDesc {
background-color: #8cb3d9;
background-image: url(black-desc.gif);
}</pre>
Default changed v2.5 to <code>"tablesorter-headerDesc"</code>. Default changed v2.1.7 to <code>"tablesorter-headerSortDown"</code>. Original default: <code>"headerSortDown"</code></div>
</td>
<td></td>
</tr>
<tr id="cssheader">
<td><a href="#" class="permalink">cssHeader</a></td>
<td>String</td>
<td>""</td>
<td>Additional CSS class applied to style the headers (<span class="version updated">v2.11</span>).
<div class="collapsible"><br>
Changed to empty string in v2.11, as the <code>"tablesorter-header"</code> class will always be added to the table headers; this option now contains any additional class names to add.
<p>Example from the blue theme:</p>
<pre class="prettyprint lang-css">.tablesorter-blue .tablesorter-header {
background-color: #99bfe6;
background-repeat: no-repeat;
background-position: center right;
padding: 4px 20px 4px 4px;
white-space: normal;
cursor: pointer;
}</pre>
Default changed v2.1.7 to <code>"tablesorter-header"</code>. Original default: <code>"header"</code></div>
</td>
<td></td>
</tr>
<tr id="cssheaderrow">
<td><a href="#" class="permalink">cssHeaderRow</a></td>
<td>String</td>
<td>""</td>
<td>Additional CSS class applied to style the header row (<span class="version updated">v2.11</span>).
<div class="collapsible"><br>
Changed to empty string in v2.11, as the <code>"tablesorter-headerRow"</code> class will always be added to a table header row; this option now contains any additional class names to add.<br>
<p>This CSS style was added in v2.4, prior to that the row would get the same class as the header cells. This class was added to make it easier to determine what element was being targeted in the plugin.</p>
</div>
</td>
<td></td>
</tr>
<tr id="cssicon">
<td><a href="#" class="permalink">cssIcon</a></td>
<td>String</td>
<td>"tablesorter-icon"</td>
<td>The CSS style used to style the header cell icon (modified v2.7; <span class="version updated">v2.21.1</span>).
<div class="collapsible"><br>
In <span class="version updated">v2.21.1</span>, adding multiple class names to this option is now properly supported.<br>
<br>
As of v2.7, the icon will only be added to the header if <strong>both</strong> the <code>cssIcon</code> option is set AND the <a href="#headertemplate"><code>headerTemplate</code></a> option includes the icon tag (<code>{icon}</code>).<br>
<br>
In v2.4, an <code><i></code> element, with this class name, is automatically appended to the header cells. To prevent the plugin from adding an <code><i></code> element to the headers, set the <code>cssIcon</code> option to an empty string.<br>
</div>
</td>
<td></td>
</tr>
<tr id="cssiconasc">
<td><a href="#" class="permalink">cssIconAsc</a></td>
<td>String</td>
<td>""</td>
<td>The CSS style added to the header cell icon when the column has an ascending sort (<span class="version">v2.18.3</span>).
<div class="collapsible"><br>
This class is only applied when the <a href="#headertemplate"><code>headerTemplate</code></a> option includes a <code>{icon}</code> tag or an HTML element with the class name from the <a href="#cssicon"><code>cssIcon</code></a> option.
</div>
</td>
<td></td>
</tr>
<tr id="cssicondesc">
<td><a href="#" class="permalink">cssIconDesc</a></td>
<td>String</td>
<td>""</td>
<td>The CSS style used to style the header cell icon when the column has a descending sort (<span class="version">v2.18.3</span>)
<div class="collapsible"><br>
This class is only applied when the <a href="#headertemplate"><code>headerTemplate</code></a> option includes a <code>{icon}</code> tag or an HTML element with the class name from the <a href="#cssicon"><code>cssIcon</code></a> option.
</div>
</td>
<td></td>
</tr>
<tr id="cssiconnone">
<td><a href="#" class="permalink">cssIconNone</a></td>
<td>String</td>
<td>""</td>
<td>The CSS style used to style the header cell icon when the column does not have a sort applied (<span class="version">v2.18.3</span>)
<div class="collapsible"><br>
This class is only applied when the <a href="#headertemplate"><code>headerTemplate</code></a> option includes a <code>{icon}</code> tag or an HTML element with the class name from the <a href="#cssicon"><code>cssIcon</code></a> option.
</div>
</td>
<td></td>
</tr>
<tr id="cssicondisabled">
<td><a href="#" class="permalink">cssIconDisabled</a></td>
<td>String</td>
<td>""</td>
<td>The CSS style used to style the header cell icon when the column sort is disabled (<span class="version">v2.28.13</span>)
<div class="collapsible"><br>
This class is only applied when the <a href="#headertemplate"><code>headerTemplate</code></a> option includes a <code>{icon}</code> tag or an HTML element with the class name from the <a href="#cssicon"><code>cssIcon</code></a> option.
</div>
</td>
<td></td>
</tr>
<tr id="cssnone">
<td><a href="#" class="permalink">cssNone</a></td>
<td>String</td>
<td>""</td>
<td>Additional CSS class applied to style the header when no sort is applied (<span class="version">v2.15</span>).
<div class="collapsible"><br>
A <code>"tablesorter-headerUnSorted"</code> class will always be added to an unsorted header cell; this option contains any additional class names to add. Currently, no themes use this class name.
</div>
</td>
<td></td>
</tr>
<tr id="cssprocessing">
<td><a href="#" class="permalink">cssProcessing</a></td>
<td>String</td>
<td>""</td>
<td>Additional CSS class applied to style the header cell while it is being sorted or filtered (v2.4; <span class="version updated">v2.11</span>).
<div class="collapsible"><br>
Changed to empty string in v2.11, as the <code>"tablesorter-processing"</code> class will always be added to a table cells during processing; this option now contains any additional class names to add.<br>
<p>This class name is added to the header cell that is currently being sorted or filted. To prevent this class name from being added, set the <a href="#showprocessing"><code>showProcessing</code></a> option to <code>false</code>.</p>
</div>
</td>
<td></td>
</tr>
<tr id="cssinfoblock">
<td><a href="#" class="permalink">cssInfoBlock</a></td>
<td>String</td>
<td>"tablesorter-infoOnly"</td>
<td>All tbodies with this class name will not have its contents sorted. (v2.2).
<div class="collapsible">
<br>
With the addition of multiple tbody sorting in v2.2, you can now insert a non-sorting tbody within the table by adding this class to the tbody.
<pre class="prettyprint lang-html"><tbody class="tablesorter-infoOnly">
<tr>
<th>The contents of this tbody</th>
</tr>
<tr>
<td>will not be sorted</td>
</tr>
</tbody></pre>
As an example, I've split up this options table into three (3) tbodies. The first contains the active options, the second is the info block with a row that only contains the text "Deprecated Options", and the last tbody contains the deprecated options. Sort the table to see how each tbody sorts separately.
<br>
<p class="tip">
<span class="label label-info">NOTE!</span> The pager plugin will only be applied to the first tbody, as always. I may work on modifying this behavior in the future, if I can figure out the best implementation.
</p>
</div>
</td>
<td></td>
</tr>
<tr id="cssnosort">
<td><span class="permalink">cssNoSort</span></td>
<td>String</td>
<td>"tablesorter-noSort"</td>
<td>Class name added to element inside header. Clicking on that element, or any elements within it won't cause a sort. (<span class="version">v2.20.0</span>).</td>
<td></td>
</tr>
<tr id="cssignorerow">
<td><a href="#" class="permalink">cssIgnoreRow</a></td>
<td>String</td>
<td>"tablesorter-ignoreRow"</td>
<td>Class name to add to a table header row if you want all cells within this row to be ignored (<span class="version">v2.18.4</span>).
<div class="collapsible">
<br>
Header rows with this class name will not be added into the <a href="#variable-headers"><code>table.config.$headers</code></a> variable. Meaning, any cells in the row will have sorting disabled, and any form element interaction within these cells will also be ignored by tablesorter.<br>
<br>
This class name should be added to header rows that contain custom HTML, like for the pager controls, custom filter row or table toolbar.
</div>
</td>
<td><a href="example-colspan.html">1</a> <a href="example-pager-ajax.html#html">2</a></td>
</tr>
<tr id="dateformat">
<td><a href="#" class="permalink">dateFormat</a></td>
<td>String</td>
<td>"mmddyyyy"</td>
<td>Set the date format. Here are the available options. (Modified v2.0.23).
<div class="collapsible">
<ul>
<li><code>"mmddyyyy"</code> (default)</li>
<li><code>"ddmmyyyy"</code></li>
<li><code>"yyyymmdd"</code></li>
</ul>
In previous versions, this option was set as "us", "uk" or "dd/mm/yy". This option was modified to better fit needed date formats. It will only work with four digit years!<br>
<br>
The sorter should be set to "shortDate" and the date format can be set in the "dateFormat" option or set for a specific columns within the "headers" option.
See <a href="example-option-date-format.html">the demo page</a> to see it working.
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
dateFormat : "mmddyyyy", // default date format
// or to change the format for specific columns,
// add the dateFormat to the headers option:
headers: {
0: { sorter: "shortDate" }, // "shortDate" with the default dateFormat above
1: { sorter: "shortDate", dateFormat: "ddmmyyyy" }, // day first format
2: { sorter: "shortDate", dateFormat: "yyyymmdd" } // year first format
}
});
});</pre>
Individual columns can be modified by adding the following (they all do the same thing), set in order of priority (Modified v2.3.1):
<ul>
<li>jQuery data <code>data-dateFormat="mmddyyyy"</code>.</li>
<li>metadata <code>class="{ dateFormat: 'mmddyyyy'}"</code>. This requires the metadata plugin.</li>
<li>headers option <code>headers : { 0 : { dateFormat : 'mmddyyyy' } }</code>.</li>
<li>header class name <code>class="dateFormat-mmddyyyy"</code>.</li>
<li>Overall <code>dateFormat</code> option.</li>
</ul>
</div>
</td>
<td><a href="example-option-date-format.html">Example</a></td>
</tr>
<tr id="debug">
<td><a href="#" class="permalink">debug</a></td>
<td>Boolean or String</td>
<td>false</td>
<td>
Set this option to provide useful for development debugging information in the console <span class="version updated">v2.30.0</span>.
<div class="collapsible">
<p>In <span class="version updated">v2.30.0</span>, set this option as a string containing either "core" and/or a specific widget name; or, a boolean value.</p>
<p>When a boolean flag is set, <em>all</em> debugging information is shown in the console.</p>
To display debugging information specific to a widget, or widgets include the widget name:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
// Show debugging info only for the filter and columnSelector widgets
// include "core" to only show the core debugging info
debug : "filter columnSelector"
});
});</pre>
The option only tests if the string contains the widget name, so <code>"corefilter"</code> would show debugging for both the core and filter widget.
</div>
</td>
<td><a href="example-option-debug.html">Example</a></td>
</tr>
<tr id="delayinit">
<td><span class="permalink">delayInit</span></td>
<td>Boolean</td>
<td>false</td>
<td>
Setting this option to true will delay parsing of all table cell data until the user initializes a sort. This speeds up the initialization process of very large tables, but the data still needs to be parsed, so the delay is still present upon initial sort.
</td>
<td><a href="example-option-delay-init.html">Example</a></td>
</tr>
<tr id="emptyto">
<td><a href="#" class="permalink">emptyTo</a></td>
<td>String</td>
<td>"bottom"</td>
<td>
Option indicating how tablesorter should deal with empty table cells. (Modified v2.1.16, <span class="version updated">v2.16.2</span>).
<div class="collapsible">
<ul>
<li><code>bottom</code> - sort empty table cells to the bottom.</li>
<li><code>top</code> - sort empty table cells to the top.</li>
<li><code>none</code> or <code>zero</code> - sort empty table cells as if the cell has the value equal to zero.</li>
<li><code>emptyMax</code> - sort empty table cells as having a value greater than the <em>max</em> (more positive) value (<span class="version">v2.16.2</span>).</li>
<li><code>emptyMin</code> - sort empty table cells as having a value greater than the <em>min</em> (more negative) value (<span class="version">v2.16.2</span>).</li>
</ul>
Individual columns can be modified by adding the following (they all do the same thing), set in order of priority:
<ul>
<li>jQuery data <code>data-empty="top"</code>.</li>
<li>metadata <code>class="{ empty: 'top'}"</code>. This requires the metadata plugin.</li>
<li>headers option <code>headers : { 0 : { empty : 'top' } }</code>.</li>
<li>header class name <code>class="empty-top"</code>.</li>
<li>Overall <code>emptyTo</code> option.</li>
</ul>
<code>emptyToBottom</code> option was added in v2.1.11, then replaced by the <code>emptyTo</code> option in v2.1.16.
</div>
</td>
<td><a href="example-option-sort-empty.html">Example</a></td>
</tr>
<tr id="headers">
<td><a href="#" class="permalink">headers</a></td>
<td>Object</td>
<td>null</td>
<td>
An object of instructions for per-"header cell" controls in the format: <code>headers: { 0: { option: setting }, ... }</code>
(<span class="version updated">v2.17.1</span>)
<div class="collapsible">
<p>
<span class="label label-warning">Warning</span> <strong>Do not</strong> use this option if your header contains multiple rows or any <code>colspan</code> or <code>rowspan</code>. Instead add a data-attribute or class name to the header (see the first demo for an example).</p>
For example, to disable sorting on the first two columns of a table: <code>headers: { 0: { sorter: false}, 1: {sorter: false} }</code>.<br>
<br>
The plugin attempts to detect the type of data that is contained in a column, but if it can't figure it out then it defaults to alphanumeric. You can easily override this by setting the header argument (or column parser).
See the full list of <a href="#parsers">default parsers here</a> or <a href="example-option-built-in-parsers.html">here</a>, or <a href="example-parsers.html">write your own</a>.
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
headers: {
// See example - Disable first header cell; parser false skips extracting content
0: { sorter: false, parser: false },
// WARNING! The "ipAddress" parser was MOVED into the "parser-network.js" file
// in v2.18.0
1: { sorter: "ipAddress" },
// See example 2: Sort column numerically & treat any text as if its value is:
2: { sorter: "digit", empty: "top" }, // zero; sort empty cells to the top
3: { sorter: "digit", string: "max" }, // maximum positive value
4: { sorter: "digit", string: "min" }, // maximum negative value
// Sort the sixth column by date & set the format
5: { sorter: "shortDate", dateFormat: "yyyymmdd" }, // year first format
// See example 3: lock the sort order
// this option will not work if added as metadata
6: { lockedOrder: "asc" },
// See Example 4: Initial sort order direction of 8th header cell
7: { sortInitialOrder: "desc" },
// Set filter widget options for this column
// See the "Applying the filter widget" demo
8: { filter: false }, // disable filter widget for this column
9: { filter: "parsed" }, // use parsed data for this column in the filter search
// Set resizable widget options for this column
10: { resizable: false } // prevent resizing of the 11th column
}
});
});</pre>
Please note that the headers index values corresponds to the table header cells index (zero-based) and <strong>not</strong> the actual columns. For example, given the following table <code>thead</code> markup, the <code>header-index</code> counts the header <code>th</code> cells and does not actually match the <code>data-column</code> index when extra rows and/or <code>colspan</code> or <code>rowspan</code> are included in any of the header cells:
<pre class="prettyprint lang-html"><thead>
<tr>
<th colspan="4" data-column="0">header-index 0</th>
</tr>
<tr>
<th data-column="0">header-index 1</th>
<th data-column="1">header-index 2</th>
<th data-column="2">header-index 3</th>
<th data-column="3">header-index 4</th>
</tr>
<tr>
<th colspan="2" data-column="0">header-index 5</th>
<th colspan="2" data-column="2">header-index 6</th>
</tr>
</thead></pre>
So, in the above example, to disable the sort of the second table column (<code>data-column</code> index of 1), the header cell of index 2 needs to be set as follows: <code>2 : { sorter : false }</code>.<br>
<br>
In <span class="version updated">v2.17.0</span>, you can reference the column(s) using a class name, id or column index.
<pre class="prettyprint lang-js">headers : {
'.first-name' : { sorter: 'text' },
'.disabled' : { sorter: false }
}</pre>
<span class="label label-warning">Warning</span> What <em>won't work</em> is if you try to target the header using a filtering selector that uses an index, e.g. <code>"th:eq()"</code>, <code>":gt()"</code>, <code>":lt()"</code>, <code>":first"</code>, <code>":last"</code>, <code>":even"</code> or <code>":odd"</code>, <code>":first-child"</code>, <code>":last-child"</code>, <code>":nth-child()"</code>, <code>":nth-last-child()"</code>, etc.
</div>
</td>
<td>
<a href="example-options-headers.html">1</a>
<a href="example-options-headers-digits-strings.html">2</a>
<a href="example-options-headers-locked.html">3</a>
<a href="example-options-headers-order.html">4</a>
<a href="example-options-headers-parser.html">5</a>
</td>
</tr>
<tr id="headertemplate">
<td><a href="#" class="permalink">headerTemplate</a></td>
<td>String</td>
<td>"{content}"</td>
<td>This is a template string which allows adding additional content to the header while it is being built (v2.7; <span class="version updated">v2.17.8</span>).
<div class="collapsible"><br>
In <span class="version updated">v2.17.8</span>, if this option is set to an empty string (<code>''</code>), an inner div will no longer be wrapped around the header content.<br>
<br>
This template string has two modifying tags: <code>{content}</code> and <code>{icon}</code>.<br>
<code>{content}</code> will be replaced by the current header HTML content.<br>
<code>{icon}</code> will be replaced by <code><i class="tablesorter-icon"></i></code>, but only if a class name is defined in the <code>cssIcon</code> option.<br>
<br>
This template string may also contain HTML, e.g (<code>'<em>{content}</em> {icon}'</code>)<br>
<br>
After the template string is built, the <code>onRenderTemplate</code> function is called to allow further manipulation. Please read more about this <a href="#onrendertemplate"><code>onRenderTemplate</code> function</a> and/or check out the example (link to the right).
</div>
</td>
<td><a href="example-option-render-template.html">Example</a></td>
</tr>
<tr id="ignorecase">
<td><span class="permalink">ignoreCase</span></td>
<td>Boolean</td>
<td>true</td>
<td>When true, text sorting will ignore the character case. If false, upper case characters will sort before lower case. (v2.2).</td>
<td></td>
</tr>
<tr id="initialized">
<td><a href="#" class="permalink">initialized</a></td>
<td>Function</td>
<td>null</td>
<td>This callback fires when tablesorter has completed initialization. (v2.2).
<div class="collapsible">
<pre class="prettyprint lang-js">$(function() {
// bind to tablesorter-initialized event BEFORE initializing tablesorter*
$("table")
.bind("tablesorter-initialized",function(e, table) {
// do something after tablesorter has initialized
});
// initialize the tablesorter plugin
$("table").tablesorter({
// this is equivalent to the above bind method
initialized : function(table) {
// do something after tablesorter has initialized
}
});
});</pre><small>* Note: bind to all initialization events before initializing tablesorter; because most of the time, if bound after, the events will fire before the binding occurs</small>.</div>
</td>
<td></td>
</tr>
<tr id="initwidgets">
<td><a href="#" class="permalink">initWidgets</a></td>
<td>Boolean</td>
<td>true</td>
<td>Apply widgets after table initializes (v2.3.5).
<div class="collapsible">
When true, all widgets set by the <code>widgets</code> option will apply after tablesorter has initialized, this is the normal behavior.<br>
<br>
If false, the each widget set by the <code>widgets</code> option will be initialized, meaning the "init" function is run, but the format function will not be run. This is useful when running the pager plugin after the table is set up. The pager plugin will initialize, then apply all set widgets.<br>
<br>
Why you ask? Well, lets say you have a table with 1000 rows that will have the pager plugin applied to it. Before this option, the table would finish its setup, all widgets would be applied to the 1000 rows, pager plugin initializes and reapplies the widgets on the say 20 rows showing; making the widget application to 100 rows unnecessary and a waste of time. So, when this option is false, widgets will only be applied to the table after the pager is set up.
</div>
</td>
<td></td>
</tr>
<tr id="widgetclass">
<td><a href="#" class="permalink">widgetClass</a></td>
<td>String</td>
<td>"widget-{name}"</td>
<td>When the table has a class name that matches the template and a widget id that matches the <code>{name}</code>, the widget will automatically be added to the table (<span class="version">v2.18.0</span>)
<div class="collapsible">
<br>
By default, this option is set to <code>'widget-{name}'</code>. So if the table has a class name of <code>widget-zebra</code> the zebra widget will be automatically added to the <code>config.widgets</code> option and applied to the table.<br>
<br>
Some widget ID's with special characters may not be detected; ID's with letters, numbers, underscores and/or dashes will be correctly detected.<br>
<br>
The template string *must* contain the <code>{name}</code> tag.
</div>
</td>
<td></td>
</tr>
<tr id="onrenderheader">
<td><a href="#" class="permalink">onRenderHeader</a></td>
<td>Function</td>
<td>null</td>
<td>
This function is called after content is to the TH tags (after the template is procressed and added). You can use this to modify the HTML in each header tag for additional styling (<span class="version updated">v2.18.0</span>).
<div class="collapsible">
<br>
In versions 2.0.6+, all TH text is wrapped in a div with a class name of "tablesorter-inner" by default. In the example below, the header cell (TH) div is given a class name (<a class="external" href="http://www.pengoworks.com/workshop/jquery/tablesorter/tablesorter.htm">source</a>).<br>
<p>Function parameters:</p>
<ul>
<li><code>index</code> - zero-based index of the current table header cell; this value is <em>not</em> indicative of the column index, as it is simply a count of header cells. So it will be effected by rowspan, colspan and multiple rows in the header.</li>
<li><code>config</code> - The current <code>table.config</code>.</li>
<li><code>$table</code> - This value is the current table jQuery object. If this function is being applied to cloned headers, as is does in the stickyHeaders widget, then this value will contain the sticky header clone added after the current table, and not the main table (<span class="version">v2.18.0</span>).</li>
</ul>
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
headerTemplate: '{content}',
onRenderHeader: function (index, config, $table) {
$(this).find('div').addClass('roundedCorners');
}
});
});</pre>and you'll end up with this HTML (only the thead is shown)<pre class="prettyprint lang-html"><thead>
<tr>
<th class="tablesorter-header"><div class="tablesorter-header-inner roundedCorners">Column 1</div></th>
<th class="tablesorter-header"><div class="tablesorter-header-inner roundedCorners">Column 2</div></th>
</tr>
</thead></pre>
<small>* Note: this function adds additional rendering time to the table if any DOM manipulation is done. Because this time will be on top of the processing time already added by the template.</small>
</div>
</td>
<td><a href="example-option-render-header.html">Example</a></td>
</tr>
<tr id="onrendertemplate">
<td><a href="#" class="permalink">onRenderTemplate</a></td>
<td>Function</td>
<td>null</td>
<td>
This function is called after the template string has been built, but before the template string is applied to the header and before the <code>onRenderHeader</code> function is called (v2.7).
<div class="collapsible">
<br>
The <code>onRenderTemplate</code> function receives a column index and template string parameters. The template string, from the <a href="#headertemplate"><code>headerTemplate</code> option</a>, will already have the <code>{icon}</code> and <code>{content}</code> tags replaced; it's just a string of formatted HTML. When done manipulating this string, return it.
<p>Function parameters:</p>
<ul>
<li><code>index</code> - zero-based index of the current table header cell; this value is <em>not</em> indicative of the column index, as it is simply a count of header cells. So it will be effected by rowspan, colspan and multiple rows in the header.</li>
<li><code>template</code> - A rendered <code>headerTemplate</code> HTML string.</li>
</ul>
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
headerTemplate: '{icon}{content}',
onRenderTemplate: function (index, template) {
return '<em>' + (index + 1) + ':</em> ' + template;
}
});
});</pre>The <code>template</code> parameter can be manipulated as a string, or if you prefer, turn it into a jQuery object (<code>var $t = $(template)</code>) to find and replace content as desired. Just make sure you return a string (<code>return $t.html()</code>)<br>
<br>
From the example function above, you'll end up with something similar to this HTML (only the thead is shown)<pre class="prettyprint lang-html"><thead>
<tr>
<th class="tablesorter-header"><div class="tablesorter-header-inner"><em>1:</em> <i class="tablesorter-icon"></i>First Name</div></th>
<th class="tablesorter-header"><div class="tablesorter-header-inner"><em>2:</em> <i class="tablesorter-icon"></i>Last Name</div></th>
</tr>
</thead></pre>
<small>* Note: If the <code>cssIcon</code> option is an empty string, the <code>{icon}</code> tag will also become an empty string.</small>
</div>
</td>
<td><a href="example-option-render-template.html">Example</a></td>
</tr>
<tr id="selectorheaders">
<td><a href="#" class="permalink">selectorHeaders</a></td>
<td>String</td>
<td>"> thead th, > thead td"</td>
<td>jQuery selectors used to find cells in the header.
<div class="collapsible">
<br>
You can change this, but the table will still need the required thead and tbody before this plugin will work properly.
<br>Added <code>></code> to the selector in v2.3 to prevent targeting nested table headers. It was modified again in v2.4 to include <code>td</code> cells within the thead.
</div>
</td>
<td></td>
</tr>
<tr id="selectorremove">
<td><a href="#" class="permalink">selectorRemove</a></td>
<td>String</td>
<td>"tr.remove-me"</td>
<td>This CSS class name can be applied to all rows that are to be removed prior to triggering a table update. (v2.1).
<div class="collapsible">
<br>
It was necessary to add this option because some widgets add table rows for styling (see the <a href="example-widgets.html">writing custom widgets demo</a>) and if a table update is triggered (<code>$('table').trigger('update');</code>) those added rows will automatically become incorporated into the table.
</div>
</td>
<td></td>
</tr>
<tr id="selectorsort">
<td><span class="permalink">selectorSort</span></td>
<td>String</td>
<td>"th, td"</td>
<td>jQuery selector of content within <a href="#selectorheaders"><code>selectorHeaders</code></a> that is clickable to trigger a sort (v2.4).</td>
<td><a href="example-option-selectorsort.html">Example</a></td>
</tr>
<tr id="resort">
<td><a href="#" class="permalink">resort</a></td>
<td>Boolean</td>
<td>true</td>
<td>When this option is <code>true</code> any applied sort on the table will be reapplied after an update method (<span class="version">v2.19.0</span>).
<div class="collapsible">
<br>
Specifically, this option applies to the <a href="#updateall"><code>updateAll</code></a>, <a href="#update"><code>update</code></a>, <a href="#addrows"><code>addRows</code></a> and <a href="#updatecell"><code>updateCell</code></a> methods and is checked after the method has completed updating the internal cache.<br>
<br>
If <code>false</code>, the widgets will still be refreshed for all but the <code>updateCell</code> method - this behavior was added in v2.19.0.<br>
<br>
<span class="label label-info">Note</span> when triggering one of the above methods, and passing a defined <code>resort</code> parameter, it will override this setting.<br>
<span class="label label-warning">Note</span> if a sort is not reapplied, problems with some widgets may occur, namely with the grouping widget.
</div>
</td>
<td></td>
</tr>
<tr id="serversidesorting">
<td><span class="permalink">serverSideSorting</span></td>
<td>Boolean</td>
<td>false</td>
<td>Set to <code>true</code> if the server is performing the sorting. The ui and events will still be used (v2.5.3).</td>
<td></td>
</tr>
<tr id="showprocessing">
<td><span class="permalink">showProcessing</span></td>
<td>Boolean</td>
<td>false</td>
<td>Show an indeterminate timer icon in the header when the table is sorted or filtered. Please note that due to javascript processing, the icon may not show as being animated. I'm looking into this further and would appreciate any feedback or suggestions with the coding (v2.4).</td>
<td><a href="example-option-show-processing.html">Example</a></td>
</tr>
<tr id="sortforce">
<td><a href="#" class="permalink">sortForce</a></td>
<td>Array</td>
<td>null</td>
<td>Use to add an additional forced sort that is <strong>prepended</strong> to <a href="#sortlist"><code>sortList</code></a>.
<div class="collapsible">
<p>
<span class="label label-warning">NOTE</span> Only when the user interacts with the table will the <code>sortForce</code> and <code>sortAppend</code> settings be applied. During initialization, and while setting the <code>sortList</code> through the API, both the <code>sortForce</code> and <code>sortAppend</code> settings are ignored. This will allow you to have explicit control over the sorting.
</p>
For example, <code>sortForce: [[0,0]]</code> will sort the first column in ascending order. After the forced sort, the user selected column(s), <em>but not during initialzation</em>, the sorting order defined in the sortList will follow. And lastly, the sort defined in the <a href="#sortappend"><code>sortAppend</code></a> option will be applied. More explicitly:<br>
<br>
There are three options to determine the sort order and this is the order of priority:
<ol>
<li><a href="#sortforce"><code>sortForce</code></a> forces the user to have this/these column(s) sorted first (null by default).</li>
<li><a href="#sortlist"><code>SortList</code></a> is the initial sort order of the columns.</li>
<li><a href="#sortappend"><code>SortAppend</code></a> is the default sort that is added to the end of the users sort selection (null by default; <span class="version updated">v2.24.0</span>).</li>
</ol>
The value of these sort options is an array of arrays and can include one or more columns. The format is an array of instructions for per-column sorting and direction in the format: <code>[[columnIndex, sortDirection], ... ]</code> where <code>columnIndex</code> is a zero-based index for your columns left-to-right and <code>sortDirection</code> is 0 for Ascending and 1 for Descending. A valid argument that sorts ascending first by column 1 and then column 2 looks like: <code>[[0,0],[1,0]]</code>.
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
sortForce : [[0,0]], // Always sort first column first
sortList : [[1,0], [2,0]], // initial sort columns (2nd and 3rd)
sortAppend : [[3,0]] // Always add this sort on the end (4th column)
});
});</pre></div>
</td>
<td><a href="example-option-sort-force.html">Example</a></td>
</tr>
<tr id="sortlist">
<td><a href="#" class="permalink">sortList</a></td>
<td>Array</td>
<td>null</td>
<td>Use to add an initial sort to the table.
<div class="collapsible">
<p>
<span class="label label-warning">NOTE</span> Only when the user interacts with the table will the <code>sortForce</code> and <code>sortAppend</code> settings be applied. During initialization, and while setting the <code>sortList</code> through the API, both the <code>sortForce</code> and <code>sortAppend</code> settings are ignored. This will allow you to have explicit control over the sorting.
</p>
The value contains an array of instructions for per-column sorting and direction in the format: <code>[[columnIndex, sortDirection], ... ]</code> where columnIndex is a zero-based index for your columns left-to-right and sortDirection is 0 for Ascending and 1 for Descending. A valid argument that sorts ascending first by column 1 and then column 2 looks like: <code>[[0,0],[1,0]]</code>. Please see <a href="#sortforce"><code>sortForce</code></a> for more details on other sort order options.<br>
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
sortList : [[1,0], [2,0]] // initial sort columns (2nd and 3rd)
});
});</pre>
This option can also be set using data-attributes (v2.3.1), jQuery data or metadata on the table:
<table class="info">
<tfoot>
<tr><td colspan="2"><strong>** Note</strong>: <code>data-sortlist</code> data is not supported in jQuery versions older than 1.4.</td></tr>
</tfoot>
<tbody>
<tr><th>jQuery data</th><td><code><table data-sortlist="[[0,0],[4,0]]"></code> <strong>**</strong></td></tr>
<tr><th>Meta data</th><td><code><table class="tablesorter {sortlist: [[0,0],[4,0]]}"></code></td></tr>
</tbody>
</table>
</div>
</td>
<td><a href="example-option-sort-list.html">Example</a></td>
</tr>
<tr id="sortappend">
<td><a href="#" class="permalink">sortAppend</a></td>
<td>Array or Object</td>
<td>null</td>
<td>Use to add an additional forced sort that will be appended to the dynamic selections by the user (<span class="version updated">v2.24.0</span>).
<div class="collapsible">
<p>
<span class="label label-warning">NOTE</span> Only when the user interacts with the table will the <code>sortForce</code> and <code>sortAppend</code> settings be applied. During initialization, and while setting the <code>sortList</code> through the API, both the <code>sortForce</code> and <code>sortAppend</code> settings are ignored. This will allow you to have explicit control over the sorting.
</p>
For example, can be used to sort people alphabetically after some other user-selected sort that results in rows with the same value like dates or money due. It can help prevent data from appearing as though it has a random secondary sort.<br>
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
sortAppend : [[1,0], [2,0]] // always append sorting of 2nd and 3rd column
});
});</pre>
The value contains an array of instructions for per-column sorting and direction in the format: <code>[[columnIndex, sortDirection], ... ]</code> where <code>columnIndex</code> is a zero-based index for your columns left-to-right and sortDirection is 0 for Ascending and 1 for Descending. A valid argument that sorts ascending first by column 1 and then column 2 looks like: <code>[[0,0],[1,0]]</code>. Please see <a href="#sortforce"><code>sortForce</code></a> for more details on other sort order options.
<p>In <span class="version updated">v2.24.0</span>, the <code>sortAppend</code> option now accepts an object containing column indexes.</p>
<p>Also, the sort direction can be set using "a" (ascending), "d" (descending), "n" (next), "s" (same) & "o" (opposite):</p>
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
sortAppend: {
0 : [[ 1,'a' ]], // always apply ascending sort
2 : [[ 3,'o' ]], // sort "o"pposite of column 2 direction
4 : [[ 5,'s' ], [ 0,'s' ]] // sort "s"ame as column 4 direction
}
});
});</pre>
</div>
</td>
<td><a href="example-option-sort-append.html">Example</a></td>
</tr>
<tr id="sortinitialorder">
<td><a href="#" class="permalink">sortInitialOrder</a></td>
<td>String</td>
<td>"asc"</td>
<td>
This sets the direction a column will sort when clicking on the header for the first time. Valid arguments are <code>"asc"</code> for Ascending or <code>"desc"</code> for Descending.<br>
<div class="collapsible">
<br>
This order can also be set by desired column using the <a href="#headers"><code>headers</code></a> option (v2.0.8).<br>
<br>
Individual columns can be modified by adding the following (they all do the same thing), set in order of priority (modified v2.3.1):
<ul>
<li>jQuery data <code>data-sortInitialOrder="asc"</code>.</li>
<li>metadata <code>class="{ sortInitialOrder: 'asc'}"</code>. This requires the metadata plugin.</li>
<li>headers option <code>headers : { 0 : { sortInitialOrder : 'asc' } }</code>.</li>
<li>header class name <code>class="sortInitialOrder-asc"</code>.</li>
<li>Overall <code>sortInitialOrder</code> option.</li>
</ul>
</div>
</td>
<td>
<a href="example-option-sort-order.html">1</a>
<a href="example-options-headers-order.html">2</a>
</td>
</tr>
<tr id="sortlocalecompare">
<td><a href="#" class="permalink">sortLocaleCompare</a></td>
<td>Boolean</td>
<td>false</td>
<td>
Boolean flag indicating if certain accented characters within the table will be replaced with their equivalent characters. (Modified v2.2).
<div class="collapsible">
<ul>
<li>This option no longer switches the sort to use the <code>String.localeCompare</code> method.</li>
<li>When this option is <code>true</code>, the text parsed from table cells will convert accented characters to their equivalent to allow the alphanumeric sort to properly sort.</li>
<li>If <code>false</code> (default), any accented characters are treated as their value in the standard unicode order.</li>
<li>The following characters are replaced for both upper and lower case (information obtained from <a class="external" href="https://sugarjs.com/docs/#/ArraySorting">sugar.js sorting equivalents</a> table):
<ul>
<li><code>áàâãä</code> replaced with <code>a</code></li>
<li><code>ç</code> replaced with <code>c</code></li>
<li><code>éèêë</code> replaced with <code>e</code></li>
<li><code>íìİîï</code> replaced with <code>i</code></li>
<li><code>óòôõöō</code> replaced with <code>o</code></li>
<li><code>úùûü</code> replaced with <code>u</code></li>
<li><code>ß</code> replaced with <code>S</code></li>
</ul>
</li>
<li>Please see the example page for instrcutions on how to modify the above equivalency table.</li>
<li>If you would like to continue using the <code>String.localeCompare</code> method, then set the <code>sortLocaleCompare</code> option to <code>false</code> and use the new <a href="#textsorter"><code>textSorter</code></a> option as follows:
<pre class="prettyprint lang-js">$('table').tablesorter({
textSorter: function(a,b) {
return a.localeCompare(b);
}
});</pre></li>
</ul>
<p class="tip">
<span class="label label-info">NOTE!</span> See the <a href="https://github.com/Mottie/tablesorter/wiki/Language">Language</a> wiki page for language specific examples and how to extend the character equivalent tables seen in the <a href="example-locale-sort.html">sortLocaleCompare demo</a>.
</p>
<del>Boolean flag indicating whenever to use javascript <code>String.localeCompare</code> method or not.<br>
This is only used when comparing text with international character strings. A sort using localeCompare will sort accented characters the same as their unaccented counterparts.</del>
</div>
</td>
<td><a href="example-locale-sort.html">Example</a></td>
</tr>
<tr id="sortreset">
<td><a href="#" class="permalink">sortReset</a></td>
<td>Boolean</td>
<td>false</td>
<td>
Setting this option to <code>true</code> will allow you to click on the table header a third time to reset the sort direction. (v2.0.27).
<div class="collapsible">
<br>Don't confuse this option with the <a href="#sortreset-method"><code>sortReset</code> method</a>. This option only resets the column sort after a third click, while the method immediately resets the entire table sort.
</div>
</td>
<td><a href="example-option-sortreset-sortrestart.html">Example</a></td>
</tr>
<tr id="sortresetkey">
<td><span class="permalink">sortResetKey</span></td>
<td>String</td>
<td>"ctrlKey"</td>
<td>The key used to reset sorting on the entire table. Defaults to the control key. The other options are <code>"shiftKey"</code> or <code>"altKey"</code> (<a class="external" href="https://developer.mozilla.org/en/DOM/MouseEvent">reference</a>).</td>
<td></td>
</tr>
<tr id="sortrestart">
<td><span class="permalink">sortRestart</span></td>
<td>Boolean</td>
<td>false</td>
<td>
Setting this option to <code>true</code> will start the sort with the <a href="#sortinitialorder"><code>sortInitialOrder</code></a> when clicking on a previously unsorted column. (v2.0.31).
</td>
<td><a href="example-option-sortreset-sortrestart.html">Example</a></td>
</tr>
<tr id="sortstable">
<td><a href="#" class="permalink">sortStable</a></td>
<td>Boolean</td>
<td>false</td>
<td>
Setting this option to <code>true</code> and sorting two rows with exactly the same content, the original sort order is maintained (<span class="version">v2.14</span>).
<div class="collapsible"><br>
This isn't exactly a <a class="external" href="http://en.wikipedia.org/wiki/Unstable_sort#Stability">stable sort</a> because the sort order maintains the original unsorted order when sorting the column in an ascending direction. When sorting the column in a descending order, the opposite of the original unsorted order is returned. If that doesn't make any sense, please refer to <a href="https://github.com/Mottie/tablesorter/issues/419">issue #419</a>.
</div>
</td>
<td><a href="example-locale-sort.html">Example</a></td>
</tr>
<tr id="sortmultisortkey">
<td><a href="#" class="permalink">sortMultiSortKey</a></td>
<td>String</td>
<td>"shiftKey"</td>
<td>
The key used to select more than one column for multi-column sorting. Defaults to the <kbd>Shift</kbd> key.
<div class="collapsible">
<p>The other options include <code>"ctrlKey"</code> or <code>"altKey"</code> (<a class="external" href="https://developer.mozilla.org/en/DOM/MouseEvent">reference</a>)</p>
To make a multisort always active, use any of the other event objects that are always <a class="external" href="https://developer.mozilla.org/en-US/docs/Glossary/Truthy">"truthy"</a> like <code>"type"</code> or <code>"bubbles"</code>. See <a href="https://github.com/Mottie/tablesorter/issues/1200">issue #1200</a>).
</div>
</td>
<td><a href="example-option-sort-key.html">Example</a></td>
</tr>
<tr id="stringto">
<td><a href="#" class="permalink">stringTo</a></td>
<td>String</td>
<td>"max"</td>
<td>
A key word indicating how tablesorter should deal with text inside of numerically sorted columns. (v2.1.16).
<div class="collapsible"><br>
String options was initially set in the header options only. Overall option added and values changed in version 2.1.16; setting the value to:
<ul>
<li><code>"max"</code> will treat any text in that column as a value greater than the <em>max</em> (more positive) value. Renamed from "max+".</li>
<li><code>"min"</code> will treat any text in that column as a value greater than the <em>min</em> (more negative) value. Renamed from "max-".</li>
<li><code>"top"</code> will always sort the text to the top of the column.</li>
<li><code>"bottom"</code> will always sort the text to the bottom of the column.</li>
<li><code>"none"</code> or <code>"zero"</code> will treat the text as if it has a value of zero.</li>
</ul>
Individual columns can be modified by adding the following (they all do the same thing), set in order of priority:
<ul>
<li>jQuery data <code>data-string="top"</code>.</li>
<li>metadata <code>class="{ string: 'top'}"</code>. This requires the metadata plugin.</li>
<li>headers option <code>headers : { 0 : { string : 'top' } }</code>.</li>
<li>header class name <code>class="string-top"</code>.</li>
<li>Overall <code>stringTo</code> option.</li>
</ul>
</div>
</td>
<td><a href="example-options-headers-digits-strings.html">Example</a></td>
</tr>
<tr id="tabindex">
<td><span class="permalink">tabIndex</span></td>
<td>Boolean</td>
<td>true</td>
<td>Add a tabindex to the headers for keyboard accessibility; this was previously always applied (<span class="version">v2.14</span>).</td>
<td></td>
</tr>
<tr id="tableClass">
<td><a href="#" class="permalink">tableClass</a></td>
<td>String</td>
<td>""</td>
<td>Additional CSS class applied to style the table (<span class="version updated">v2.11</span>).
<div class="collapsible"><br>
Changed to empty string in v2.11, as the <code>"tablesorter"</code> class will always be added to the table; this option now contains any additional class names to add.
<p>This class was required in the default markup in version 2.0.5. But in version 2.0.6, it was added as an option.</p>
Modify this option if you are not using the default css, or if you are using a completely custom stylesheet.
</div>
</td>
<td></td>
</tr>
<tr id="theme">
<td><a href="#" class="permalink">theme</a></td>
<td>String</td>
<td>"default"</td>
<td>This option will add a theme css class name to the table <code>"tablesorter-{theme}"</code> for styling (v2.4; <span class="version updated">v2.18.0</span>).
<div class="collapsible">
<br>
<span class="label alert">*NOTE*</span> If creating a custom theme file, make sure to include a filter definition to hide filtered out rows:
<pre class="prettyprint lang-css">.filtered { display: none; }</pre>
<p><span class="label label-info">Note</span> the <code>.filtered</code> class can be modified using the <a href="#widget-filter-filteredrow"><code>filter_filteredRow</code> option</a>.</p>
When changing this theme option (the actual theme name is inside parentheses), make sure that the appropriate css theme file has also been loaded. Default theme files include:
<a href="themes.html" target="_blank" title="open themes in a new window">see all themes</a><br>
<iframe style="width:100%;height:300px;" src="themes.html"></iframe>
<hr>
<h3>uitheme widget</h3>
<p>You will need to use the uitheme widget to extend the theme to apply css from jQuery UI, Bootstrap (v3 & earlier) or other css libraries.</p>
<h4>Modify a theme</h4>
<p>If you want to modify the existing themes ("jui" and "bootstrap"), it can be done as follows:</p>
<p>Modify the class names by extending from the <a href="#variable-themes"><code>$.tablesorter.themes</code></a> variable</p>
<p><span class="label label-info">Note</span> there is no need to extend from the entire list of class names, just include the key:value pairs that are being changed:</p>
<pre class="prettyprint lang-js">// Extend a theme to modify any of the default class names
$.extend($.tablesorter.themes.jui, {
// change default jQuery uitheme icons - find the full list of icons
// here: http://jqueryui.com/themeroller/ (hover over them for their name)
table : 'ui-widget ui-widget-content ui-corner-all', // table classes
caption : 'ui-widget-content',
// header class names
header : 'ui-widget-header ui-corner-all ui-state-default', // header classes
sortNone : '',
sortAsc : '',
sortDesc : '',
active : 'ui-state-active', // applied when column is sorted
hover : 'ui-state-hover', // hover class
// icon class names
icons : 'ui-icon', // icon class added to the <i> in the header
iconSortNone : 'ui-icon-carat-2-n-s ui-icon-caret-2-n-s', // "caret" class renamed in jQuery v1.12.0
iconSortAsc : 'ui-icon-carat-1-n ui-icon-caret-1-n',
iconSortDesc : 'ui-icon-carat-1-s ui-icon-caret-1-s',
// other
filterRow : '',
footerRow : '',
footerCells : '',
even : 'ui-widget-content', // even row zebra striping
odd : 'ui-state-default' // odd row zebra striping
});</pre>
<h4>Custom theme</h4>
To add a new uitheme, define it as follows (replace "custom" with the name of your theme):
<pre class="prettyprint lang-js">$.tablesorter.themes.custom = {
table : 'table', // table classes
header : 'header', // header classes
footerRow : '',
footerCells: '',
icons : 'icon', // icon class added to the <i> in the header
sortNone : 'sort-none', // unsorted header
sortAsc : 'sort-asc', // ascending sorted header
sortDesc : 'sort-desc', // descending sorted header
active : 'sort-active', // applied when column is sorted
hover : 'hover', // hover class
filterRow : 'filters', // class added to the filter row
even : 'even', // even row zebra striping
odd : 'odd' // odd row zebra striping
}</pre>
Then use it by adding the name of your theme to the <code>theme</code> option:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
// set the new theme name from $.tablesorter.themes here
theme : 'custom',
// add {icon} to template (if needed)
headerTemplate: '{content}{icon}',
// make sure to initialize uitheme widget
widgets : ["uitheme"]
});
});</pre>
</div>
</td>
<td><a href="themes.html">Example</a></td>
</tr>
<tr id="textattribute">
<td><a href="#" class="permalink">textAttribute</a></td>
<td>String</td>
<td>"data-text"</td>
<td>This data-attribute can be added to any tbody cell and can contains alternate cell text (<span class="version">v2.16.0</span>).
<div class="collapsible">
<br>
This option contains the name of the data-attribute used by the <a href="#textextraction"><code>textExtraction</code></a> function. Add it to the cell(s) as follows:
<pre class="prettyprint lang-html"><td data-text="1">First repository</td></pre>
<span class="label label-info">Note</span> This option only works when the <a href="#textextraction"><code>textExtraction</code></a> option is set to "basic".
<p><span class="label alert">*NOTE*</span> It is important to know that the filter widget is set to use extracted (parsed) content as a parsed value and the raw cell content as unparsed values; and most of the time the filter widget is searching unparsed content. But, when a data-attribute is used, both the parsed and raw cached data will contain the <em>exact same content</em> (<a href="https://github.com/Mottie/tablesorter/issues/983">ref</a>)!</p>
</div>
</td>
<td></td>
</tr>
<tr id="textextraction">
<td><a href="#" class="permalink">textExtraction</a></td>
<td>Multiple*</td>
<td>"basic"</td>
<td>Defines which method is used to extract data from a table cell for sorting (<span class="version updated">v2.19.0</span>)
<div class="collapsible">
<br>
* <span class="label label-info">Note</span> This option accepts multiple types (String, Object or Function); see below for further details.
<p></p>
In <span class="version updated">v2.19.0</span>, the code was further optimized. When set to <code>"basic"</code> (the default), the textExtraction code will check for data-attributes, otherwise, any other string value setting will skip the data-attribute value check; because of this change, there is a noticable lessening of initialization time in Internet Explorer.
<p></p>
In <span class="version updated">v2.17.0</span>, the <code>textExtraction</code> column can also be referenced by using a jQuery selector (e.g. class name, id or column index) that points to a table <em>header</em> cell.<br>
<pre class="prettyprint lang-js">textExtraction : {
// 'jQuery thead cell selector' : function ( new method )
'.styled' : function(node, table, cellIndex) {
return $(node).find('strong').text();
},
// columnIndex : function ( original method )
2 : function(node, table, cellIndex) {
return $(node).find('img').attr('title');
}
}</pre>
<span class="label label-warning">Warning</span> What <em>won't work</em> is if you try to target the header using a filtering selector that uses an index, e.g. <code>"th:eq()"</code>, <code>":gt()"</code>, <code>":lt()"</code>, <code>":first"</code>, <code>":last"</code>, <code>":even"</code> or <code>":odd"</code>, <code>":first-child"</code>, <code>":last-child"</code>, <code>":nth-child()"</code>, <code>":nth-last-child()"</code>, etc.<br>
<br>
As of version 2.16.0,
<ul>
<li>The default text extraction method has been renamed and updated to get data from a data-attribute (set by the <a href="#textattribute"><code>textAttribute</code></a> option).</li>
<li>If you need to support older versions of IE, this may add a significant delay to the table initialization especially for large tables; in this case, set the <code>textExtraction</code> option to any name other than "basic".</li>
<li>Also, this option can now be set using a data-attribute named "data-text-extraction" on the table.</li>
</ul>
You can customize the text extraction by writing your own text extraction function "myTextExtraction" which you define like:
<pre class="prettyprint lang-js">var myTextExtraction = function(node, table, cellIndex) {
// extract data from markup and return it
// originally: return node.childNodes[0].childNodes[0].innerHTML;
return $(node).find('selector').text();
}
$(function() {
$("#myTable").tablesorter( { textExtraction: myTextExtraction } );
});</pre>
tablesorter will pass the current table cell object for you to parse and return. Thanks to Josh Nathanson for the examples; updated to a jQuery example by Rob G (Mottie).
<p>Now if the text you are finding in the script above is say a number, then just include the <a href="#headers"><code>headers</code></a> sorter option to specify how to sort it. Also in this example, we will specify that the special textExtraction code is only needed for the second column (<code>1</code> because we are using a zero-based index). All other columns will ignore this textExtraction function.</p>
<p>Added <code>table</code> and <code>cellIndex</code> variables to the <code>textExtraction</code> function in version 2.1.2 (this is not part of the original plugin).</p>
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
textExtraction: {
1: function(node, table, cellIndex) {
return $(node).find("span:last").text();
}
},
headers: {
1: { sorter : "digit" }
}
});
});</pre>
The built-in option is <code>"basic"</code> (modified v2.16.0) which is the equivalent of doing this inside of the textExtraction function: <code>$(node).text();</code>.
</div>
</td>
<td><a href="example-option-text-extraction.html">Example</a></td>
</tr>
<tr id="namespace">
<td><a href="#" class="permalink">namespace</a></td>
<td>String</td>
<td>undefined</td>
<td>
This option should contain a unique namespace for each table; it is used when binding to event listeners (<span class="version">v2.15.7</span>).
<div class="collapsible">
<br>
Notes about this namespace option:
<ul>
<li>If a namesspace is not defined, a (hopefully) unique random namespace will be generated.</li>
<li>If defined, any "non-word" characters (anything not "a-z", "0-9" or "_") within the namespace will be removed.</li>
<li>Added or not, the namespace will be saved with a leading period (e.g. ".myuniquetableid")</li>
</ul>
<pre class="prettyprint lang-js">$(function() {
$("#mytable").tablesorter({
// if table id = "mytable", this namespace is saved as ".mytable"
namespace : $('#mytable')[0].id;
});
});</pre>
</div>
</td>
<td></td>
</tr>
<tr id="numbersorter">
<td><a href="#" class="permalink">numberSorter</a></td>
<td>Function</td>
<td>null</td>
<td>
Replace the default number sorting algorithm with a custom one using this option (<span class="version">v2.12</span>).
<div class="collapsible">
<br>
Here is an example:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
numberSorter : function(a, b, direction, maxColumnValue) {
// direction; true = ascending; false = descending
// maxColumnValue = the maximum value of that column (ignoring its sign)
return a - b;
}
});
});</pre>The direction parameter (boolean) is merely for informational purposes as the plugin automatically switches <code>a</code> and <code>b</code> depending on the sort direction ( i.e. there's no need to worry about reverse sorting, it's taken care of by the plugin ).
</div>
</td>
<td></td>
</tr>
<tr id="pointerclick">
<td><a href="#" class="permalink">pointerClick</a></td>
<td>String</td>
<td>"click"</td>
<td>Use this option to change the click event (<span class="version">v2.22.0</span>)
<div class="collapsible">
<p>Change this option if want to change the click event that is bound to the table headers. Add multiple events separated by spaces.</p>
<span class="label label-warning">Warning</span> If this option is set to fire multiple events (e.g. <code>'mouseup pointerup'</code>), sorting may be initialized twice in rapid succession and make it appear that nothing changed.
</div>
</td>
<td></td>
</tr>
<tr id="pointerdown">
<td><a href="#" class="permalink">pointerDown</a></td>
<td>String</td>
<td>"mousedown"</td>
<td>Use this option to change the pointer down event (<span class="version">v2.22.0</span>)
<div class="collapsible">
<p>Change this option if you're using pointer events (or the <a class="external" href="https://github.com/jquery/PEP">pointer events polyfill</a>). Add multiple events separated by spaces.</p>
<span class="label label-warning">Warning</span> If this option is set to fire multiple events (e.g. <code>'mousedown pointerdown'</code>), sorting may be initialized twice in rapid succession and make it appear that nothing changed.
</div>
</td>
<td></td>
</tr>
<tr id="pointerup">
<td><a href="#" class="permalink">pointerUp</a></td>
<td>String</td>
<td>"mouseup"</td>
<td>Use this option to change the pointer up event (<span class="version">v2.22.0</span>)
<div class="collapsible">
<p>Change this option if you're using pointer events (or the <a class="external" href="https://github.com/jquery/PEP">pointer events polyfill</a>). Add multiple events separated by spaces.</p>
<span class="label label-warning">Warning</span> If this option is set to fire multiple events (e.g. <code>'mouseup pointerup'</code>), sorting may be initialized twice in rapid succession and make it appear that nothing changed.
</div>
</td>
<td></td>
</tr>
<tr id="textsorter">
<td><a href="#" class="permalink">textSorter</a></td>
<td>Function</td>
<td>null</td>
<td>
Replace the default sorting algorithm with a custom one using this option (<span class="version updated">v2.27.6</span>) - <span class="label label-warning">*NOTE*</span> The parameters have changed!!.
<div class="collapsible">
<br>
Include a script like <a class="external" href="https://github.com/overset/javascript-natural-sort">naturalSort.js</a> as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
textSorter : naturalSort
});
});</pre>
or use the localeCompare sort
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
// replace the OVERALL text sorter function
textSorter: function(a, b, direction, columnIndex, table) {
// direction: true = ascending; false = descending
// columnIndex: zero-based index of the current table column being sorted
// table: table DOM element (access options by using table.config)
return a.localeCompare(b);
}
});
});</pre>In <span class="version updated">v2.27.6</span>, the <code>textSorter</code> option will allow setting a sorter per column index or class name (column indexes were added in <span class="version updated">v2.12</span>):
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
textSorter : {
// replace INDIVIDUAL COLUMN text sorter functions
0 : function(a, b, direction, columnIndex, table) {
// same as $.tablesorter.sortText (basic alphabetical sort)
// direction: true = ascending; false = descending
// columnIndex: zero-based index of the current table column being sorted
// table: table DOM element (access options by using table.config)
return a > b ? 1 : (a < b ? -1 : 0);
},
// same as the function in column 0 above (modified in v2.12)
1 : $.tablesorter.sortText,
// renamed v2.12 from $.tablesorter.sortText - performs natural sort
'.nat-sort' : $.tablesorter.sortNatural,
// alphanumeric sort from sugar v2.0+ (https://sugarjs.com/docs/#/Array/getOption)
'.sugar-sort' : Sugar.Array.getOption('sortCollate')
}
});
});</pre>The direction parameter (boolean) is merely for informational purposes as the plugin automatically switches <code>a</code> and <code>b</code> depending on the sort direction ( i.e. there's no need to worry about reverse sorting, it's taken care of by the plugin ).
</div>
</td>
<td>
<a href="example-option-custom-sort.html">1</a>
<a href="example-option-textsorter-semver.html">2</a>
</td>
</tr>
<tr id="usnumberformat">
<td><a href="#" class="permalink">usNumberFormat</a></td>
<td>Boolean</td>
<td>true</td>
<td>
Indicates how tablesorter should deal with a numerical format: (v2.1.3).
<div class="collapsible">
<table class="info"><tbody>
<tr>
<th><code>true</code></th>
<td class="right">U.S.</td>
<td><code>1,234,567.89</code></td>
</tr>
<tr>
<th><code>false</code></th>
<td class="right">German:<br>French:</td>
<td><code>1.234.567,89</code><br><code>1 234 567,89</code></td>
</tr>
</tbody></table>
</div>
</td>
<td><a href="../index.html">Example</a></td>
</tr>
<tr id="widgets">
<td><span class="permalink">widgets</span></td>
<td>Array</td>
<td>[ ] (empty array)</td>
<td>
Initialize widgets using this option ( e.g. <code>widgets : ['zebra']</code>, or custom widgets <code>widgets: ['zebra', 'myCustomWidget'];</code>, see <a href="example-widgets.html">this demo</a> on how to write your own custom widget ).
</td>
<td><a href="example-widget-zebra.html">Example</a></td>
</tr>
<tr id="widthfixed">
<td><a href="#" class="permalink">widthFixed</a></td>
<td>Boolean</td>
<td>false</td>
<td>
Indicates if tablesorter should apply fixed percentage-based widths to the table columns (modified v2.4).
<div class="collapsible">
Prior to v2.4, this option set pixel widths to added colgroups to fix the column widths. This is useful for the Pager companion.
<br>
<del>Requires the <a href="#Download-Addons">jQuery dimension plugin</a> to work.</del> This is now part of the jQuery core.
</div>
</td>
<td><a href="example-pager.html">Example</a></td>
</tr>
<tr id="widgetoptions">
<td><a href="#" class="permalink">widgetOptions</a></td>
<td>Object</td>
<td>{ }</td>
<td>
In version 2.1, all widget options have been moved into this option. This is a move to store all widget specific options in one place so as not to polute the main table options. All current widgets have been modified to use this new option. (v2.1).
<div class="collapsible">
<br>
Previously documented widget options <a href="#widgetzebra"><code>widgetZebra</code></a>, <a href="#widgetcolumns"><code>widgetColumns</code></a> and <a href="#widgetuitheme"><code>widgetUitheme</code></a> will be retained for backwards compatibility.<br>
<br>
Use the <a href="#widgetoptions"><code>widgetOptions</code></a> option as follows, please note that each option is followed by a comma (except the last one):
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
// initialize a bunch of widgets (the order doesn't matter)
widgets: ["zebra", "uitheme", "columns", "filter", "resizable", "stickyHeaders"],
widgetOptions: {
// *** COLUMNS WIDGET ***
// change the default column class names primary is the 1st column
// sorted, secondary is the 2nd, etc
columns: [
"primary",
"secondary",
"tertiary"
],
// If true, the class names from the columns option will also be added
// to the table tfoot
columns_tfoot: true,
// If true, the class names from the columns option will also be added
// to the table thead
columns_thead: true,
// *** FILTER WIDGET ***
// css class name added to the filter cell (string or array)
filter_cellFilter: '',
// If there are child rows in the table (rows with class name from
// "cssChildRow" option) and this option is true and a match is found
// anywhere in the child row, then it will make that row visible;
// default is false
filter_childRows: false,
// ( filter_childRows must be true ) if true = search
// child rows by column; false = search all child row text grouped
filter_childByColumn: false,
// if true, include matching child row siblings
filter_childWithSibs: true,
// if true, allows using '#:{query}' in AnyMatch searches
// ( column:query )
filter_columnAnyMatch: true,
// If true, a filter will be added to the top of each table column.
filter_columnFilters: true,
// css class name added to the filter row & each input in the row
// (tablesorter-filter is ALWAYS added)
filter_cssFilter: '',
// data attribute in the header cell that contains the default (initial)
// filter value
filter_defaultAttrib: 'data-value',
// add a default column filter type "~{query}" to make fuzzy searches
// default; "{q1} AND {q2}" to make all searches use a logical AND.
filter_defaultFilter: {},
// filters to exclude, per column
filter_excludeFilter: {},
// jQuery selector string (or jQuery object)
// of external filters
filter_external: '',
// class added to filtered rows; needed by pager plugin
filter_filteredRow: 'filtered',
// ARIA-label added to filter input/select; {{label}} is replaced by
// the column header "data-label" attribute, if it exists, or it uses the
// column header text
filter_filterLabel : 'Filter "{{label}}" column by...',
// add custom filter elements to the filter row
filter_formatter: null,
// Customize the filter widget by adding a select dropdown with content,
// custom options or custom filter functions;
// see http://goo.gl/HQQLW for more details
filter_functions: null,
// hide filter row when table is empty
filter_hideEmpty: true,
// Set this option to true to hide the filter row initially. The row is
// revealed by hovering over the filter row or giving any filter
// input/select focus. In v2.26.6, a function can be used to set when
// to hide the filter row.
filter_hideFilters: false,
// Set this option to false to keep the searches case sensitive
filter_ignoreCase: true,
// if true, search column content while the user types (with a delay)
// or, set a minimum number of characters that must be present before
// a search is initiated. In v2.27.3, this option can contain an
// object with column indexes or classnames; "fallback" is used
// for undefined columns
filter_liveSearch: true,
// global query settings ('exact' or 'match'); overridden by
// "filter-match" or "filter-exact" class
filter_matchType: {
'input': 'exact',
'select': 'exact'
},
// a header with a select dropdown & this class name will only show
// available (visible) options within the drop down
filter_onlyAvail: 'filter-onlyAvail',
// default placeholder text (overridden by any header
// "data-placeholder" setting)
filter_placeholder: {
search: '',
select: ''
},
// jQuery selector string of an element used to reset the filters.
filter_reset: null,
// Reset filter input when the user presses escape
// normalized across browsers
filter_resetOnEsc: true,
// Use the $.tablesorter.storage utility to save the most recent filters
filter_saveFilters: false,
// Delay in milliseconds before the filter widget starts searching;
// This option prevents searching for every character while typing
// and should make searching large tables faster.
filter_searchDelay: 300,
// allow searching through already filtered rows in special
// circumstances; will speed up searching in large tables if true
filter_searchFiltered: true,
// include a function to return an array of values to be added to the
// column filter select
filter_selectSource: null,
// filter_selectSource array text left of the separator is added to
// the option value, right into the option text
filter_selectSourceSeparator: '|',
// Set this option to true if filtering is performed on the
// server-side.
filter_serversideFiltering: false,
// Set this option to true to use the filter to find text from the
// start of the column. So typing in "a" will find "albert" but not
// "frank", both have a's; default is false
filter_startsWith: false,
// If true, ALL filter searches will only use parsed data. To only
// use parsed data in specific columns, set this option to false
// and add class name "filter-parsed" to the header
filter_useParsedData: false,
// *** RESIZABLE WIDGET ***
// If this option is set to false, resized column widths will not
// be saved. Previous saved values will be restored on page reload
resizable: true,
// If this option is set to true, a resizing anchor
// will be included in the last column of the table
resizable_addLastColumn: false,
// If this option is set to true, the resizable handle will extend
// into the table footer
resizable_includeFooter: true,
// Set this option to the starting & reset header widths
resizable_widths: [],
// Set this option to throttle the resizable events
// set to true (5ms) or any number 0-10 range
resizable_throttle: false,
// When true, the last column will be targeted for resizing,
// which is the same has holding the shift and resizing a column
resizable_targetLast: false,
// *** SAVESORT WIDGET ***
// If this option is set to false, new sorts will not be saved.
// Any previous saved sort will be restored on page reload.
saveSort: true,
// *** STICKYHEADERS WIDGET ***
// stickyHeaders widget: extra class name added to the sticky header
// row
stickyHeaders: '',
// jQuery selector or object to append sticky headers to
stickyHeaders_appendTo: null,
// jQuery selector or object to attach sticky headers scroll listener to
// overridden by xScroll & yScroll settings
stickyHeaders_attachTo: null,
// jQuery selector or object to monitor horizontal scroll position
// (defaults: xScroll > attachTo > window)
stickyHeaders_xScroll: null,
// jQuery selector or object to monitor vertical scroll position
// (defaults: yScroll > attachTo > window)
stickyHeaders_yScroll: null,
// number or jquery selector targeting the position:fixed element
stickyHeaders_offset: 0,
// scroll table top into view after filtering
stickyHeaders_filteredToTop: true,
// added to table ID, if it exists
stickyHeaders_cloneId: '-sticky',
// trigger "resize" event on headers
stickyHeaders_addResizeEvent: true,
// if false and a caption exist, it won't be included in the
// sticky header
stickyHeaders_includeCaption: true,
// The zIndex of the stickyHeaders, allows the user to adjust this
// to their needs
stickyHeaders_zIndex: 2,
// *** STORAGE WIDGET ***
// set storage type; this overrides any storage_useSessionStorage setting
// use the first letter of (l)ocal, (s)ession or (c)ookie
storage_storageType: '',
// DEPRECATED: allows switching between using local & session storage
storage_useSessionStorage: false,
// alternate table id (set if grouping multiple tables together)
storage_tableId: '',
// table attribute to get the table ID, if storage_tableId
// is undefined
storage_group: '', // defaults to "data-table-group"
// alternate url to use (set if grouping tables across
// multiple pages)
storage_fixedUrl: '',
// table attribute to get the fixedUrl, if storage_fixedUrl
// is undefined
storage_page: '',
// *** ZEBRA WIDGET ***
// class names to add to alternating rows
// [ "even", "odd" ]
zebra: [
"even",
"odd"
]
}
});
});</pre></div>
</td>
<td><a href="example-widget-zebra.html">Example</a></td>
</tr>
</tbody>
<!-- non-sorting tbody -->
<tbody id="other" class="tablesorter-infoOnly">
<tr><th colspan="5">Utility Options</th></tr>
</tbody>
<tbody>
<tr id="checkboxclass">
<td><a href="#" class="permalink">checkboxClass</a></td>
<td>String</td>
<td>"checked"</td>
<td>Used by the "checkbox" parser in the <code>parser-input-select.js</code> file (<span class="version">v2.22.2</span>; <span class="version updated">v2.25.0</span>).
<div class="collapsible">
<p>When using the checkbox parser, this class name is added to the row along with this class name plus the column index when the targeted checkbox is checked.</p>
<p>For example, if the named parser file has been loaded & "sorter-checkbox" class is added to the first column header, then any checked checkbox in the first column will have <code>"checked checked-0"</code> class names added to the row.</p>
Checkboxes in any other column, not targeted by the parser, will be ignored and no extra row class names will be added.
</div>
</td>
<td><a href="example-widget-output.html">Example</a></td>
</tr>
<tr id="checkboxvisible">
<td><a href="#" class="permalink">checkboxVisible</a></td>
<td>Boolean</td>
<td>true</td>
<td>Used by the "checkbox" parser in the <code>parser-input-select.js</code> file (<span class="version updated">v2.24.6</span>).
<div class="collapsible">
<p>When using the checkbox parser, this setting is used when a checkbox inside a header cell is changed; if <code>true</code>, only same column checkboxes within visible rows are modified to match the header checkbox.</p>
<p>If <code>false</code>, same column checkboxes in <em>all</em> rows are modified to match the status of the header checkbox.</p>
</div>
</td>
<td><a href="example-widget-output.html">Example</a></td>
</tr>
<tr id="data">
<td><span class="permalink">data</span></td>
<td>Object, Array</td>
<td>undefined</td>
<td>Storage for processed table build widget (<code>widget-build-table.js</code>) data (array, object, string) (<span class="version">v2.11</span>).</td>
<td><a href="example-widget-build-table.html">Example</a></td>
</tr>
<tr id="daterange">
<td><span class="permalink">dateRange</span></td>
<td>Numeric</td>
<td>50</td>
<td>
Used by the two digit year parser (<code>parser-date-two-digit-year.js</code>) to set the date range (<span class="version">v2.14</span>).</td>
<td><a href="example-parsers-dates.html">Example</a></td>
</tr>
<tr id="globalize">
<td><a href="#" class="permalink">globalize</a></td>
<td>object</td>
<td>null</td>
<td>
This option is used by multiple parsers to localize the language (<span class="version">v2.24.0</span>; <span class="version updated">v2.24.1</span>).
<div class="collapsible"><br>
This option is meant to be used with the <a class="external" href="https://github.com/jquery/globalize">jQuery Globalize</a> library along with CLDR data.
<p>See the <a href="example-widget-grouping.html#globalization">Globalization</a> section in the group widget demo for details on how to set it up.</p>
<p>Currently, the globalize (<code>parser-globalize.js</code>), month (<code>parser-date-month.js</code>) & weekday (<code>parser-date-weekday.js</code>) parsers utilize this option.</p>
<pre class="prettyprint lang-js">$(function() {
$('table').tablesorter({
// globalize : { lang: 'en' } // for ALL columns
// or, per column by using the column index
globalize : {
0 : { lang: 'fr', Globalize : Globalize('fr'), raw: 'MMM d, y G' },
2 : { lang: 'fr' }
}
});
});</pre>
</div>
</td>
<td><a href="example-parsers-globalize.html">2</a> <a href="example-parsers-dates.html">2</a></td>
</tr>
<tr id="ignorechildrow">
<td><a href="#" class="permalink">ignoreChildRow</a></td>
<td>Boolean</td>
<td>false</td>
<td>
Used by the input-select parser indicate if changes to child row content is to be ignored (<span class="version">v2.28.10</span>)
<div class="collapsible"><br>
Change this setting to ignore input, textarea and select changes inside of child rows:
<pre class="prettyprint lang-js">$(function() {
$('table').tablesorter({
ignoreChildRow : true
});
});</pre>
See <a href="https://github.com/Mottie/tablesorter/pull/1399">pull request #1399</a> for more information.
</div>
</td>
<td></td>
</tr>
<tr id="imgattr">
<td><a href="#" class="permalink">imgAttr</a></td>
<td>String</td>
<td>"alt"</td>
<td>
Used by the image parser to grab the image attribute content (<span class="version">v2.17.5</span>; moved to tablesorter core in <span class="version updated">v2.18.0</span>; see <a href="#parsers"><code>config.parsers</code></a>).
<div class="collapsible"><br>
Change this setting to grab a different image attribute to be used for sorting:
<pre class="prettyprint lang-js">$(function() {
$('table').tablesorter({
// parse image title (value to be used while sorting & filtering)
imgAttr : 'title',
headers : {
0 : { sorter: 'image' } // this parser is auto-detected, but will only work on the first image
}
});
});</pre>
</div>
</td>
<td></td>
</tr>
</tbody>
<!-- non-sorting tbody -->
<tbody id="deprecated" class="tablesorter-infoOnly">
<tr><th colspan="5">Deprecated/Removed Options</th></tr>
</tbody>
<tbody>
<tr id="fixedurl">
<td><a href="#" class="permalink alert">fixedUrl</a></td>
<td>String</td>
<td>undefined</td>
<td>
This option is being <span class="label label-danger">deprecated</span> in v2.21.3!
It has been replaced by <a href="#widget-storage-fixed-url"><code>widgetOptions.storage_fixedUrl</code></a>; but is still available for backwards compatibility.
<div class="collapsible"><br>
This option was added to set a specific page when storing data using the <a href="#function-storage"><code>$.tablesorter.storage</code></a> code (<span class="version">v2.12</span>).
<br>
More specifically, when the storage function is used, it attempts to give every table a unique identifier using both the page <strong>url</strong> and table <strong>ID</strong> (or index on the page if no id exists). This option allows you to override the current page url (<em>it doesn't need to be a url, just some constant value</em>) and save data for multiple tables across a domain.<br>
<br>
The table url & id can also be overridden by setting table data attributes <code>data-table-page</code> (url) and <code>data-table-group</code> (id)<br>(e.g. <code><table class="tablesorter" data-table-page="mydomain" data-table-group="financial">...</table></code>)<br>
<br>
For a bit more detail, specifically on how to use the new storage function options for a custom widget, please refer to <a href="https://github.com/Mottie/tablesorter/issues/389#issuecomment-26594259">issue #389</a>.
</div>
</td>
<td></td>
</tr>
<tr id="cssallowclicks">
<td><a href="#" class="permalink alert">cssAllowClicks</a></td>
<td>String</td>
<td></td>
<td>This option was <span class="label label-danger">removed</span>!
It has been replaced by <a href="#cssnosort">cssNoSort</a> which does the opposite of what this class name was supposed to do.
<div class="collapsible">
<p>This option was not working as intended, so it was completely removed - sorry for the lack of notice.</p>
<p>Previous default was <code>"tablesorter-allowClicks"</code></p>
Class name added to table header which allows clicks to bubble up. (added v2.18.1; removed in v2.20.0).
</div>
</td>
<td></td>
</tr>
<tr id="widgetcolumns">
<td><a href="#" class="permalink alert">widgetColumns</a></td>
<td></td>
<td></td>
<td>
This option was <span class="label label-danger">removed</span> in v2.21.2!
It has been replaced by <a href="#widget-columns"><code>widgetOptions.columns</code></a>.
<div class="collapsible">
<br>
Default value: <code>{ css: [ "primary", "secondary", "tertiary" ] }</code> (Object with Array)
<p></p>
When the column styling widget is initialized, it automatically applied the default class names of <code>"primary"</code> for the primary sort, <code>"secondary"</code> for the next sort, <code>"tertiary"</code> for the next sort, and so on (add more as needed)... (v2.0.17).
Use the <a href="#widgetcolumns"><code>widgetColumns</code></a> option to change the css class name as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["columns"], // initialize column styling of the table
widgetColumns: { css: ["primary", "secondary", "tertiary" ] }
});
});</pre></div>
</td>
<td></td>
</tr>
<tr id="widgetuitheme">
<td><a href="#" class="permalink alert">widgetUitheme</a></td>
<td></td>
<td></td>
<td>
This option was <span class="label label-danger">removed</span> in v2.4!
It has been replaced by <a href="#widget-uitheme"><code>widgetOptions.uitheme</code></a>.
<div class="collapsible">
<br>
Default value: <code>{ css: [ "ui-icon-arrowthick-2-n-s", "ui-icon-arrowthick-1-s", "ui-icon-arrowthick-1-n" ] }</code> (Object with Array)
<p></p>
Used when the ui theme styling widget is initialized. It automatically applies the default class names of <code>"ui-icon-arrowthick-2-n-s"</code> for the unsorted column, <code>"ui-icon-arrowthick-1-s"</code> for the descending sort and <code>"ui-icon-arrowthick-1-n"</code> for the ascending sort. (v2.0.9).
Find more jQuery UI class names by hovering over the Framework icons on this page: <a class="external" href="http://jqueryui.com/themeroller/">http://jqueryui.com/themeroller/</a><br>
<br>
Use the <a href="#widgetuitheme"><code>widgetUitheme</code></a> option to change the css class name as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["uitheme"], // initialize ui theme styling widget of the table
widgetUitheme: {
css: [
"ui-icon-carat-2-n-s", // Unsorted icon
"ui-icon-carat-1-s", // Sort up (down arrow)
"ui-icon-carat-1-n" // Sort down (up arrow)
]
}
});
});</pre></div>
</td>
<td></td>
</tr>
<tr id="widgetzebra">
<td><a href="#" class="permalink alert">widgetZebra</a></td>
<td></td>
<td></td>
<td>
This option was <span class="label label-danger">removed</span> in v2.4!
It has been replaced by <a href="#widget-zebra"><code>widgetOptions.zebra</code></a>.
<div class="collapsible">
<br>
Default value: <code>{ css: [ "even", "odd" ] }</code> (Object with Array)
<p></p>
When the zebra striping widget is initialized, it automatically applied the default class names of <code>"even"</code> and <code>"odd"</code>.
Use the <a href="#widgetzebra"><code>widgetZebra</code></a> option to change the css class name as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["zebra"], // initialize zebra striping of the table
widgetZebra: { css: [ "normal-row", "alt-row" ] }
});
});</pre></div>
</td>
<td></td>
</tr>
</tbody>
</table>
<a id="Widget-options"></a>
<h1>Widget & Pager Options</h1>
<table class="tablesorter-blue compatibility" data-sortlist="[[0,0]]">
<thead>
<tr><th>Widget Priority</th><th>Name</th><th>Requires jQuery</th><th>Limiting function</th></tr>
</thead>
<tbody>
<tr><td>30</td><td>columns</td><td>v1.2.6</td><td></td></tr>
<tr><td>50</td><td>filter</td><td>v1.4.3</td><td>1.4.3 (nextUntil & delegate)</td></tr>
<tr><td>Last</td><td>pager plugin</td><td>v1.2.6</td><td></td></tr>
<tr><td>55</td><td>pager widget</td><td>v1.7</td><td>1.7 (on)</td></tr>
<tr><td>40</td><td>resizable</td><td>v1.4.1*</td><td>1.4.1 (parseJSON)*</td></tr>
<tr><td>20</td><td>saveSort</td><td>v1.4.1</td><td>1.4.1 (parseJSON)*</td></tr>
<tr><td>60</td><td>stickyHeaders</td><td>v1.4.3</td><td>1.4.3 (isWindow)**</td></tr>
<tr><td>10</td><td>uitheme</td><td>v1.2.6</td><td></td></tr>
<tr><td>90</td><td>zebra</td><td>v1.2.6</td><td></td></tr>
</tbody>
</table>
<div class="tip">
<p></p>
tablesorter widgets have many options, and to better organize them, they now are grouped together inside of the <code>widgetOptions</code>. Thanks to thezoggy for putting together this jQuery-widget compatibility table, but please note:
<ul>
<li>The applied order of widget is dependent of the widget priority, from low to high.</li>
<li>Widget priority values do not need to be unique. Any new widget without a defined priority will automatically have a priority of <code>10</code>.</li>
<li>The pager, being a plugin, is actually initialized after tablesorter has initialized and all selected widgets applied.</li>
<li>* The <code>saveSort</code> and <code>resizable</code> widgets use the <a href="#function-storage"><code>$.tablesorter.storage</code></a> function by default and thus need the <code>parseJSON</code> function which is available in jQuery 1.4.1+.</li>
<li>** The <code>stickyHeaders</code> widget was updated in v2.18.0 to use <code>$.isWindow</code> for the <code>xScroll</code> & <code>yScroll</code> options; and therefore now requires jQuery 1.4.3+.</li>
</ul>
<br class="clear">
<span class="label label-info">TIP!</span> Click on the link in the property column to reveal full details (or <a href="#" class="toggleAll">toggle</a>|<a href="#" class="showAll">show</a>|<a href="#" class="hideAll">hide</a> all) or double click to update the browser location.
</div>
<table id="widget-options" class="tablesorter-blue options" data-sortlist="[[0,0]]">
<thead>
<tr>
<th class="property">Property</th>
<th class="type">Type</th>
<th class="defaults">Default</th>
<th class="descrip sorter-false">Description</th>
<th class="examples sorter-false">Link</th>
</tr>
</thead>
<tfoot>
<tr>
<th class="property">Property</th>
<th class="type">Type</th>
<th class="defaults">Default</th>
<th class="descrip">Description</th>
<th class="examples">Link</th>
</tr>
</tfoot>
<tbody>
<tr id="widget-columns">
<td><a href="#" class="permalink">columns</a></td>
<td>Array</td>
<td>[ "primary", "secondary", "tertiary" ]</td>
<td>
Columns widget: When the column styling widget is initialized, it automatically applied the default class names of <code>"primary"</code> for the primary sort, <code>"secondary"</code> for the next sort, <code>"tertiary"</code> for the next sort, and so on (add more as needed)... (Modified v2.1).
<div class="collapsible">
<br>
Use the <a href="#widget-columns"><code>"columns"</code></a> option to change the css class name as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["columns"], // initialize column styling of the table
widgetOptions : {
columns: [ "primary", "secondary", "tertiary" ]
}
});
});</pre></div>
</td>
<td><a href="example-widget-columns.html">Example</a></td>
</tr>
<tr id="widget-columns-thead">
<td><a href="#" class="permalink">columns_thead</a></td>
<td>Boolean</td>
<td>true</td>
<td>
Columns widget: If true, the class names from the <a href="#widget-columns"><code>columns</code></a> option will also be added to the table thead (v2.4).
<div class="collapsible">
<br>
Use the <a href="#widget-columns-thead"><code>"columns_thead"</code></a> option to add the column class names to the thead as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["columns"], // initialize column styling of the table
widgetOptions : {
columns_thead: true
}
});
});</pre></div>
</td>
<td><a href="example-widget-columns.html">Example</a></td>
</tr>
<tr id="widget-columns-tfoot">
<td><a href="#" class="permalink">columns_tfoot</a></td>
<td>Boolean</td>
<td>true</td>
<td>
Columns widget: If true, the class names from the <a href="#widget-columns"><code>columns</code></a> option will also be added to the table tfoot (v2.4).
<div class="collapsible">
<br>
Use the <a href="#widget-columns-tfoot"><code>"columns_tfoot"</code></a> option to add the column class names to the tfoot as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["columns"], // initialize column styling of the table
widgetOptions : {
columns_tfoot: true
}
});
});</pre></div>
</td>
<td><a href="example-widget-columns.html">Example</a></td>
</tr>
<tr id="widget-filter-childrows">
<td><a href="#" class="permalink">filter_childRows</a></td>
<td>Boolean</td>
<td>false</td>
<td>
Filter widget: If there are child rows in the table (rows with class name from <a href="#csschildrow"><code>"cssChildRow"</code></a> option) and this option is <code>true</code> and a match is found anywhere in the child row, then it will make that row visible.
(Modified v2.1).
<div class="collapsible">
<p><span class="label label-info">*NOTE*</span> When using this option, please be aware that all child row content will be obtained from each table cell using <code>textContent</code>, so none of the markup will be preserved. Also, carriage returns (<code><br></code>) will not be included. To account for the loss of white space, especially after carriage returns, please add an extra space to the end of the line. Using <code>innerText</code>, could have been an option for preserving the white space, but it is not standardized across all browsers (<a class="external" href="http://perfectionkills.com/the-poor-misunderstood-innerText/">ref</a>).</p>
Use the <a href="#widget-filter-childrows"><code>filter_childRows</code></a> option to include child row text as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_childRows : true
}
});
});</pre></div>
</td>
<td></td>
</tr>
<tr id="widget-filter-child-by-column">
<td><a href="#" class="permalink">filter_childByColumn</a></td>
<td>Boolean</td>
<td>false</td>
<td>
Filter widget: If <code>true</code>, queries will search child row content by column (<span class="version">v2.22.0</span>).
<div class="collapsible">
<p>The <code>filter_childRows</code> option must also be <code>true</code> for this option to work.</p>
<p>If <code>false</code>, and the <code>filter_childRows</code> option is <code>true</code>, then queries in <em>any column</em> will search all child content, as before this option was added.</p>
<p></p>
Use the <a href="#widget-filter-child-by-column"><code>filter_childByColumn</code></a> option as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_childRows : true,
filter_childByColumn : true
}
});
});</pre>
</div>
</td>
<td><a href="example-child-rows-filtered.html#child-by-column">Example</a></td>
</tr>
<tr id="widget-filter-child-with-sibs">
<td><a href="#" class="permalink">filter_childWithSibs</a></td>
<td>Boolean</td>
<td>true</td>
<td>
Filter widget: include all sibling rows of the matching child row (<span class="version">v2.23.4</span>).
<div class="collapsible">
<p>Both <code>filter_childRows</code> & <code>filter_childByColumn</code> options must be set to <code>true</code> for this option to work.</p>
<p>If <code>false</code>, this option will only show the child row that matches the filter; and its parent row.</p>
Use the <a href="#widget-filter-child-with-sibs"><code>filter_childWithSibs</code></a> option as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: [ "filter" ],
widgetOptions : {
filter_childRows : true,
filter_childByColumn : true,
// only show matching child row & parent
filter_childWithSibs : false
}
});
});</pre>
</div>
</td>
<td><a href="example-widget-filter-childrows.html">Example</a></td>
</tr>
<tr id="widget-filter-column-anymatch">
<td><a href="#" class="permalink">filter_columnAnyMatch</a></td>
<td>Boolean</td>
<td>true</td>
<td>
Filter widget: If <code>true</code>, allows using "#:{query}" in anyMatch searches (<span class="version">v2.20.0</span>).
<div class="collapsible">
<br>
Users can use the anymatch input to target a specific column, using a one-based index.
<p></p>
For example: In the table below, searching for <code>2:aa</code> in an anymatch filter will result in "Phillip Aaron Wong" and "Aaron" showing in the First Name column.
<p></p>
See live examples in the <a href="example-widget-filter-any-match.html#anymatch_searches">Filter Widget External Search</a> demo.
</div>
</td>
<td></td>
</tr>
<tr id="widget-filter-columnfilters">
<td><a href="#" class="permalink">filter_columnFilters</a></td>
<td>Boolean</td>
<td>true</td>
<td>
Filter widget: If <code>true</code>, a filter will be added to the top of each table column (v2.4).
<div class="collapsible">
<br>
Use the <a href="#widget-filter-columnFilters"><code>filter_columnFilters</code></a> option as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_columnFilters : true
}
});
});</pre></div>
</td>
<td></td>
</tr>
<tr id="widget-filter-cellfilter">
<td><a href="#" class="permalink">filter_cellFilter</a></td>
<td>String or Array</td>
<td>""</td>
<td>Filter widget: Additional CSS class applied to each filter cell (<span class="version">v2.18.0</span>).
<div class="collapsible"><br>
When the filter row is built, each table cell (<code><td></code>) will get the class name from this option.
<ul>
<li>If this option is a plain string, all filter row cells will get the text applied as a class name.
<pre class="prettyprint lang-js">// "table-filter-cell" class added to all filter row td's
filter_cellFilter : 'table-filter-cell'</pre>
</li>
<li>If this option is an array, then each filter row cell will get the text from the associate array element applied as a class name.
<pre class="prettyprint lang-css">.hidden { display: none; }</pre>
<pre class="prettyprint lang-js">// hiding second & fourth columns using associated css
filter_cellFilter : [ '', 'hidden', '', 'hidden' ]</pre>
</li>
</ul>
<p>Use the <a href="#widget-filter-cellfilter"><code>filter_cellFilter</code></a> option to add an extra css class name as follows:</p>
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
// css class applied to the table row containing the filters & the inputs within that row
// or [ "filter-cell0", "filter-cell1", "filter-cell2", etc... ]
filter_cellFilter : "tablesorter-filter-cell"
}
});
});</pre><span class="label label-info">Note</span> The cells from this option are also contained within the <a href="#variable-filters"><code>config.$filters</code></a> variable.
</div>
</td>
<td><a href="example-widget-filter.html">Example</a></td>
</tr>
<tr id="widget-filter-cssfilter">
<td><a href="#" class="permalink">filter_cssFilter</a></td>
<td>String or Array</td>
<td>""</td>
<td>Filter widget: Additional CSS class applied to each filter (<span class="version updated">v2.15</span>).
<div class="collapsible"><br>
As of v2.15, this option can also contain an array of class names that are to be applied to input filters.<br>
<br>
Changed default to an empty string in v2.11, as the <code>"tablesorter-filter"</code> class will always be added to the filter; this option now contains any additional class names to add.
<p>Use the <a href="#widget-filter-cssfilter"><code>filter_cssFilter</code></a> option to add an extra css class name as follows:</p>
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
// css class applied to the table row containing the filters & the inputs within that row
// or [ "filter0", "filter1", "filter2", etc... ]
filter_cssFilter : "tablesorter-filter"
}
});
});</pre>
</div>
</td>
<td><a href="example-widget-filter.html">Example</a></td>
</tr>
<tr id="widget-defaultfilter">
<td><a href="#" class="permalink">filter_defaultFilter</a></td>
<td>Object</td>
<td>{ }</td>
<td>
Filter widget: Add a default filter type to a column (<span class="version">v2.17.8</span>).
<div class="collapsible">
<br>
<span class="label warning">Warning</span> If a column has a default filter set, the user <strong>will not</strong> be able to use other filters.<br>
<br>
Use the <a href="#widget-defaultfilter"><code>filter_defaultFilter</code></a> option as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_defaultFilter : {
// target a column by class name or column index (zero-based)
'.fuzzy' : '~{q}',
2 : '{q}=',
// for default "anyMatches" use the column length as the index
// e.g. if your table has 5 columns (0,1,2,3,4), then set the anyMatch column as 5.
5 : '{q} or {q}' // any match column
}
}
});
});</pre>
Set up the column string as follows:
<ul>
<li>Add the desired filter type symbol along with <code>{query}</code> or <code>{q}</code> to maintain positioning</li>
<li>Symbols can be added to the beginning <code>"~{query}"</code> (default fuzzy search) or end <code>"{q}="</code> (default exact search)</li>
<li>For symbols that separate queries, like "AND", "OR" or "-" (range):
<ul>
<li>Add one additional <code>{q}</code> tag.</li>
<li>For example, to add a default "OR" search, use <code>"{q} OR {q}"</code>.</li>
<li>If the user enters <code>"a b c d"</code> the column will be filtered using <code>"a OR b OR c OR d"</code>, so there is no need to add more <code>{q}</code> tags within the string; adding more will likely mess up the results.</li>
<li>If the user only enters <code>"a"</code>, then the column will be filtered using <code>"a OR a"</code> so as not to cause other issues.</li>
</ul>
</li>
<li><span class="label label-info">Note</span> It is not possible to set up a default filter search within a query. So the "wild" filter search will not work as intended (e.g. <code>{q}*</code> and <code>{q}?</code> are essentially the same as <code>{q}</code>.</li>
</ul>
</div>
</td>
<td><a href="example-widget-filter-any-match.html">Example</a></td>
</tr>
<tr id="widget-filter-exclude-filter">
<td><a href="#" class="permalink">filter_excludeFilter</a></td>
<td>Object</td>
<td>{ }</td>
<td>Filter widget: Additional CSS class applied to each filter (<span class="version">v2.17.8</span>).
Exclude a filter type(s) for a column.
<div class="collapsible">
<br>
Use the <a href="#widget-excludefilter"><code>filter_excludeFilter</code></a> option as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_excludeFilter : {
// target a column by class name or column index (zero-based)
'.title' : 'range',
// separate multiple filter types using spaces
2 : 'range notMatch exact'
}
}
});
});</pre>
Exclusion names must be separated by a comma. Here is a full list of filter type names:
<ul>
<li><code>and</code> - logical AND type filter (using <code>foo AND bar</code> or <code>foo && bar</code>).</li>
<li><code>or</code> - logical OR type filter (using <code>foo OR bar</code> or <code>foo|bar</code>).</li>
<li><code>exact</code> - exact match (using <code>"</code> or <code>=</code>).</li>
<li><code>fuzzy</code> - fuzzy match (<code>~</code>)</li>
<li><code>notMatch</code> - not match (<code>!</code> or <code>!=</code>)</li>
<li><code>operators</code> - comparison filters (<code>< <= >= ></code>)</li>
<li><code>range</code> - range (<code> - </code> or <code> to </code>)</li>
<li><code>regex</code> - regex (<code>/\d/</code>)</li>
<li><code>wild</code> - wild card matching (<code>?</code> for single characters, <code>*</code> for multiple characters not including spaces, <del>or <code>|</code> or <code> OR </code> for a logical OR</del> (the "or" filter type was separated from "wild" in v2.22.2).</li>
</ul>
</div>
</td>
<td></td>
</tr>
<tr id="widget-filter-external">
<td><a href="#" class="permalink">filter_external</a></td>
<td>String</td>
<td>""</td>
<td>
Filter widget: jQuery selector string of inputs, outside of the table, to be used for searching table content (<span class="version">v2.15</span>).
<div class="collapsible">
<br>
Set this option to be a jQuery selector string, or jQuery object, pointing to any external inputs that are to be used for searching the table.<br>
<br>
Use the <a href="#widget-filter-external"><code>filter_external</code></a> option as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_external : '.search'
}
});
});</pre>
These external inputs have one requirement, they must have a <code>data-column="#"</code>, where the <code>#</code> targets the column (zero-based index), pointing to a specific column to search.<br>
<pre class="prettyprint lang-html"><input class="search" type="search" data-column="0" placeholder="Search first column"></pre>
If you want to search all columns, using the updated "any match" method, set the data column value to "all":<br>
<pre class="prettyprint lang-html"><input class="search" type="search" data-column="all" placeholder="Search entire table"></pre>
The updated any matching code will now automatically update all associated inputs with the latest search.
<br>
This option replaces <a href="#widget-filter-anymatch"><code>filter_anyMatch</code></a>.
</div>
</td>
<td><a href="example-widget-filter-any-match.html">Example</a></td>
</tr>
<tr id="widget-filter-filteredrow">
<td><a href="#" class="permalink">filter_filteredRow</a></td>
<td>String</td>
<td>"filtered"</td>
<td>
Filter widget: This is the class name applied to all rows that do not match the filter (hidden rows); used by pager plugin (<span class="version">v2.10</span>).
<div class="collapsible">
<br>
<span class="label alert">*NOTE*</span> If creating a custom theme, make sure to include this definition (set to <code>display:none</code> or the filter widget will appear to be broken!
</div>
</td>
<td></td>
</tr>
<tr id="widget-filter-filterlabel">
<td><a href="#" class="permalink">filter_filterLabel</a></td>
<td>String</td>
<td>'Filter "{{label}}" column by...'</td>
<td>
This option contains the ARIA-label value to be added to the filter input or select (<span class="version">v2.29.4</span>).
<div class="collapsible">
<p>
By default, a <code>{{label}}</code> is included in the setting to insert a column label. The content is obtained from the header cell's <code>data-label</code> attribute (do not include the <code>data-</code> prefix), if it exists, or the column header text. See the "First Name" column on the example page.
</p>
<p>
More complex labels may be included by adding multiple "data-attributes". For example, the following option:
<pre class="pretty-print lang-js">filter_filterLabel : 'Filter the {{column-name}}, the {{ordinal-number}} column{{label-extra}}{{default-filter}}'</pre>
with this header cell HTML
<pre class="pretty-print lang-html"><th data-column-name="last name" data-ordinal-number="second" data-default-filter=", using a fuzzy search" data-label-extra="">
Last
<th></pre>
would result in an ARIA-label of <code>'Filter the last name, the second column, using a fuzzy search'</code>
</p>
<span class="label label-info">Note:</span>
<ul>
<li>The <code>data-</code> prefix must not be added in the placeholders.</li>
<li>The empty <code>data-label-extra</code> attribute did add any content to the resulting label.</li>
<li>If an included data-attribute does not exist on the header, it will be replaced by the header text.</li>
</ul>
</div>
</td>
<td><a href="example-widget-filter.html#demo">Example</a></td>
</tr>
<tr id="widget-filter-formatter">
<td><a href="#" class="permalink">filter_formatter</a></td>
<td>Object</td>
<td>null</td>
<td>
Filter widget: This option allows you to add custom controls within the filter widget row (v2.7.7; <span class="version updated">v2.17.0</span>).<br>
<div class="collapsible">
<br>
In <span class="version updated">v2.17.0</span>, the <code>filter_formatter</code> column can also be referenced by using a jQuery selector (e.g. class name or ID) that points to a table <em>header</em> cell.<br>
<pre class="prettyprint lang-js">filter_formatter : {
".col-value" : function($cell, indx) {
return $.tablesorter.filterFormatter.uiSpinner( $cell, indx, {
...
});
}
}</pre>
<span class="label label-warning">Warning</span> What <em>won't work</em> is if you try to target the header using a filtering selector that uses an index, e.g. <code>"th:eq()"</code>, <code>":gt()"</code>, <code>":lt()"</code>, <code>":first"</code>, <code>":last"</code>, <code>":even"</code> or <code>":odd"</code>, <code>":first-child"</code>, <code>":last-child"</code>, <code>":nth-child()"</code>, <code>":nth-last-child()"</code>, etc.<br>
<br>
A new file has been included named "widget-filter-formatter-jui.js" & "widget-filter-formatter-html5.js". The files include code to add jQuery UI and HTML5 controls via the <a href="#widget-filter-formatter"><code>filter_formatter</code></a> option.<br>
<br>
Most of the formatter functions have an option named <code>valueToHeader</code> which, when <code>true</code> adds a span to the header cell above the filter row and updates it with the current control's value (see <a href="example-widget-filter-formatter-2.html">example 2</a>). If the option exists and is set to <code>false</code>, then the current value is added to the control's handle and css can be used to create a popup to show the current value (see <a href="example-widget-filter-formatter-1.html">example 1</a>).<br>
<br>
Another custom option named <code>addToggle</code> is included with the "uiSpinner", "html5Color" and "html5Number" code. This allows the user to disable the control to show all table rows. For the single sliders, "uiSlider" and "html5Range", the minimum value is used to clear the filter (show all rows).<br>
<br>
The options included for each jQuery UI control only show basic options, but any or all of the jQuery UI options for that control can be included.<br>
<ul>
<li>
To add the jQuery UI slider, follow this example:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_formatter : {
// column index `0` or use a jQuery selector `"th:contains('Discount')"`
0 : function($cell, indx) {
return $.tablesorter.filterFormatter.uiSpinner( $cell, indx, {
value : 0, // starting value
min : 0, // minimum value
max : 50, // maximum value
step : 1, // increment value by
addToggle: true, // Add a toggle to enable/disable the control
valueToHeader: false // add current slider value to the header cell
});
}
}
}
});
});</pre>Any of the other <a class="external" href="http://api.jqueryui.com/spinner/">jQuery UI spinner widget options</a> can also be included.<br>
<br>
</li>
<li>Filter formatter functions include: "uiSpinner", "uiSlider", "uiRange" (uiSlider ranged), "uiDatepicker" (range only), "html5Number", "html5Range" and "html5Color".</li>
<li>
For other examples, please refer to the example pages. Formatter part 1 (example 1) adds jQuery UI controls to the filter row, while formatter part 2 (example 2) adds HTML5 controls, if supported, to the filter row.
</li>
</ul>
</div>
</td>
<td>
<a href="example-widget-filter-formatter-1.html">1</a>
<a href="example-widget-filter-formatter-2.html">2</a>
</td>
</tr>
<tr id="widget-filter-functions">
<td><a href="#" class="permalink">filter_functions</a></td>
<td>Object</td>
<td>null</td>
<td>
Filter widget: Customize the filter widget by adding a select dropdown with content, custom options or custom filter functions (v2.3.6; <span class="version updated">v2.17.0</span>).
<div class="collapsible">
<br>
In <span class="version updated">v2.22.0</span>, a <a href="example-widget-filter-custom-search.html#how_to_add_custom_filter_types"><code>data</code></a> parameter was added to that long list of parameters.<p></p>
<span class="label alert">*WARNING*</span> In a future update, the filter function parameters will be cleaned up and changed as follows!
<pre class="prettyprint lang-js">filter_functions : {
// function(e, n, f, i, $r, c, data) {} <- current parameters
0 : function(c, data) {} // planned change (version undetermined)
}</pre>The <code>e</code> (exact table cell text), <code>n</code> (normalized table cell text), <code>f</code> (filter input value), <code>i</code> (column index) and <code>$r</code> (current row; jQuery object) are all already included in the <a href="example-widget-filter-custom-search.html#how_to_add_custom_filter_types"><code>data</code></a> object.
<p></p>
In <span class="version updated">v2.17.0</span>, the <code>filter_functions</code> column can also be referenced by using a jQuery selector (e.g. class name or ID) that points to a table <em>header</em> cell.<br>
<pre class="prettyprint lang-js">filter_functions : {
".col-date" : {
"< 2004" : function (e, n, f, i, $r, c, data) {
return n < Date.UTC(2004, 0, 1); // < Jan 1 2004
},
...
}
}</pre>
<span class="label label-warning">Warning</span> What <em>won't work</em> is if you try to target the header using a filtering selector that uses an index, e.g. <code>"th:eq()"</code>, <code>":gt()"</code>, <code>":lt()"</code>, <code>":first"</code>, <code>":last"</code>, <code>":even"</code> or <code>":odd"</code>, <code>":first-child"</code>, <code>":last-child"</code>, <code>":nth-child()"</code>, <code>":nth-last-child()"</code>, etc.<br>
<br>
Use the <a href="#widget-filter-functions"><code>"filter_functions"</code></a> option in three different ways:
<br>
<ul>
<li>
Make a sorted select dropdown list of all column contents. Repeated content will be combined.
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions: {
filter_functions: {
// Add select menu to this column
// set the column value to true, and/or add "filter-select" class name to header
0 : true
}
}
});
});</pre>
Alternately, instead of setting the column filter funtion to true, give the column header a class name of "filter-select". See the <a href="example-widget-filter-custom.html">demo</a>.<br><br>
</li>
<li>
Make a select dropdown list with custom option settings. Each option must have a corresponding function which returns a boolean value; return true if there is a match, or false with no match.
<h4>Regex example</h4>
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions: {
// function variables:
// e = exact text from cell
// n = normalized value returned by the column parser
// f = search filter input value
// i = column index
// $r = jQuery element of current row
// c = table.config
// data = combined filter data - see filter widget "custom searches" demo, look under "How to add Custom filter types"
filter_functions: {
// Add these options to the select dropdown (regex example)
2 : {
"A - D" : function(e, n, f, i, $r, c, data) { return /^[A-D]/.test(e); },
"E - H" : function(e, n, f, i, $r, c, data) { return /^[E-H]/.test(e); },
"I - L" : function(e, n, f, i, $r, c, data) { return /^[I-L]/.test(e); },
"M - P" : function(e, n, f, i, $r, c, data) { return /^[M-P]/.test(e); },
"Q - T" : function(e, n, f, i, $r, c, data) { return /^[Q-T]/.test(e); },
"U - X" : function(e, n, f, i, $r, c, data) { return /^[U-X]/.test(e); },
"Y - Z" : function(e, n, f, i, $r, c, data) { return /^[Y-Z]/.test(e); }
}
}
}
});
});</pre>
<h4>Comparison example</h4>
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions: {
// function variables:
// e = exact text from cell
// n = normalized value returned by the column parser
// f = search filter input value
// i = column index
// $r = jQuery element of current row
// c = table.config
// data = combined filter data - see filter widget "custom searches" demo, look under "How to add Custom filter types"
filter_functions: {
// Add these options to the select dropdown (numerical comparison example)
// Note that only the normalized (n) value will contain numerical data
// If you use the exact text, you'll need to parse it (parseFloat or parseInt)
4 : {
"< $10" : function(e, n, f, i, $r, c, data) { return n < 10; },
"$10 - $100" : function(e, n, f, i, $r, c, data) { return n >= 10 && n <=100; },
"> $100" : function(e, n, f, i, $r, c, data) { return n > 100; }
}
}
}
});
});</pre>
Note: if the <code>filter_ignoreCase</code> option is <code>true</code>, it DOES alter the normalized value (n) by making it all lower case.<br><br>
</li>
<li>
Make a custom filter for the column.
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions: {
// function variables:
// e = exact text from cell
// n = normalized value returned by the column parser
// f = search filter input value
// i = column index
// $r = jQuery element of current row
// c = table.config
// data = combined filter data - see filter widget "custom searches" demo, look under "How to add Custom filter types"
filter_functions: {
// Exact match only
1 : function(e, n, f, i, $r, c, data) {
return e === f;
}
}
}
});
});</pre>
Note: if the <code>filter_ignoreCase</code> option is <code>true</code>, it DOES alter the normalized value (n) by making it all lower case.<br><br>
</li>
</ul>
</div>
</td>
<td><a href="example-widget-filter-custom.html">Example</a></td>
</tr>
<tr id="widget-filter-hideempty">
<td><a href="#" class="permalink">filter_hideEmpty</a></td>
<td>Boolean</td>
<td>true</td>
<td>
Filter widget: Set this option to <code>false</code> to always show the filter row; by default, the filter row is completely hidden when no rows exist within the tbody (<span class="version">v2.15</span>).
<div class="collapsible">
<br>
Use the <a href="#widget-filter-hideempty"><code>filter_hideEmpty</code></a> option as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_hideEmpty : false
}
});
});</pre></div>
</td>
<td></td>
</tr>
<tr id="widget-filter-hidefilters">
<td><a href="#" class="permalink">filter_hideFilters</a></td>
<td>Boolean, or Function</td>
<td>false</td>
<td>
Filter widget: Set this option to <code>true</code> to hide the filter row initially. The row is revealed by hovering over the visible portion of the filter row or by giving any filter input/select focus (tab key) (v2.4; <span class="version updated">v2.26.6</span>).
<div class="collapsible">
<br>
Use the <a href="#widget-filter-hidefilters"><code>filter_hideFilters</code></a> option as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_hideFilters : true
}
});
});</pre>You can change the style (thickness) of the hidden filter row in the tablesorter theme css. Look for <code>.tablesorter-filter-row</code> (revealed row) and <code>.tablesorter-filter-row.hideme</code> (for the hidden row) css definitions.
In <span class="version updated">v2.26.6</span>, this setting can also contain a function.
<ul>
<li>When this function returns a boolean value, it signifies whether the filter row should or should not be hidden (see the details in <a href="https://github.com/Mottie/tablesorter/issues/477#issuecomment-229352896">this issue</a>.</li>
<li>If this function does not return a boolean value, the value of the filters are checked and if no search queries are found, the filter row will be hidden.</li>
</ul>
Example of function setting:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_hideFilters : function(config) {
// get an array of filter queries (don't use the value from
// `config.lastSearch` because this code will modify it;
// unless you extend it)
var search = $.tablesorter.getFilters(config.$table);
// ignore any query is column 2 (zero-based index)
search.splice(2,1);
// return true to hide the filter row, false to show it
return search.join("") === "";
}
}
});
});</pre></div>
</td>
<td><a href="example-widget-filter.html">Example</a></td>
</tr>
<tr id="widget-filter-ignorecase">
<td><a href="#" class="permalink">filter_ignoreCase</a></td>
<td>Boolean</td>
<td>true</td>
<td>
Filter widget: Set this option to <code>false</code> to make the column content search case-sensitive, so typing in "a" will not find "Albert". (v2.3.4)
<div class="collapsible">
<br>
Use the <a href="#widget-filter-ignorecase"><code>filter_ignoreCase</code></a> option as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_ignoreCase : false
}
});
});</pre></div>
</td>
<td><a href="example-widget-filter.html">Example</a></td>
</tr>
<tr id="widget-filter-livesearch">
<td><a href="#" class="permalink">filter_liveSearch</a></td>
<td>Boolean, Number or Object</td>
<td>true</td>
<td>
Filter widget: If <code>true</code>, a search of the column content will occur as the user types, with the delay set in the <code>filter_searchDelay</code> option (v2.9; <span class="version updated">v2.27.3</span>).
<div class="collapsible">
<br>
This option, when <code>false</code> allows you to disable the live search behavior, so that a filter is only applied when the user presses <kbd>Enter</kbd> (or uses <kbd>Esc</kbd> to clear and cancel the search).<br>
<br>
If this option is set to a number, e.g. <code>4</code>, a search of the column content will not initiate until this minimum number of characters are entered into the input.
<p>In <span class="version">v2.27.3</span>, this option can be set as an object containing specific column zero-based indexes, or class names. For undefined columns, include a <code>"fallback"</code> value otherwise undefined columns will be set as <code>false</code>.</p>
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_liveSearch : {
// when false, the user must press enter to blur the input to trigger the search
3 : false,
// the query will initiate when 5 or more characters are entered into the filter
4 : 5,
// no live search on the last three columns (using a header class name)
'.last-3-columns' : false,
// for columns that aren't defined; this will set the fallback value
// otherwise the fallback defaults to false.
'fallback' : true
}
}
});
});</pre>
</div>
</td>
<td></td>
</tr>
<tr id="widget-filter-matchtype">
<td><a href="#" class="permalink">filter_matchType</a></td>
<td>Object</td>
<td>{ 'input': 'exact', 'select': 'exact' }</td>
<td>
Filter widget: This option sets the global setting that applied to either input or select filters (<span class="version">v2.25.5</span>)
<div class="collapsible">
<p>A basic input filter will match the filter query until a "and" and "or" type search is performed.</p>
<p>By default, select filters and "and" and "or type searchs will look for an exact match, and to override this behavior you *had* to add a "filter-match" class to the columns to allow partial matches.</p>
<p>This option allows you to set a global "match" setting and save you the trouble of adding a bunch of classes.</p>
<p>There are only two options: "exact" and "match"; and it defaults to "exact" if anything else is entered.</p>
In the demo, try searching for <code>super or man</code> in the first column.
</div>
</td>
<td><a href="example-widget-formatter.html">Example</a></td>
</tr>
<tr id="widget-filter-onlyAvail">
<td><a href="#" class="permalink">filter_onlyAvail</a></td>
<td>String</td>
<td>"filter-onlyAvail"</td>
<td>
Filter widget: If a header contains a select dropdown and this class name, only the available (visible) options in the column will show (<span class="version">v2.10.1</span>; <span class="version updated">v2.17.6</span>).
<div class="collapsible">
<br>
In <span class="version">v2.17.6</span>, columns with the only available class name set, that <em>are not</em> currently being filtered will only show the available options. Conversely, the column(s) with a selected option will show all options.<br>
<br>
This option is useful after one or more columns have been filtered, then the column select filter with this class applied will only show the contents of the column within the dropdown that are currently visible. See the <a href="example-widget-filter-custom.html">custom filter widget</a> demo "Discount" column for an example (sort the "First Name" column first).<br>
<br>
<span class="label label-warning">Caution:</span> The main issue with this functionality is with keyboard accessibility. If the keyboard is used to select an option, only the first and default options will be available for chosing. The only way to select other options is with the mouse.
</div>
</td>
<td><a href="example-widget-filter-custom.html">Example</a></td>
</tr>
<tr id="widget-filter-placeholder">
<td><a href="#" class="permalink">filter_placeholder</a></td>
<td>object</td>
<td>{ search : '', select : '' }</td>
<td>
Filter widget: Set global filter input placeholder text for search inputs and selects (<span class="version">v2.16</span>).
<div class="collapsible">
<br>
Any search type input added to the filter row will automatically get a placeholder attribute added, the source of this placeholder text is from the following sources, in order of priority:
<ul>
<li>Header cell data (<code>table.config.$headers.eq(0).data('placeholder', 'search for...');</code></li>
<li>Header cell data-attribute (<code><th data-placeholder="Find Rank...">Rank</th></code>)</li>
<li>Global <code>filter_placeholder.search</code> setting.</li>
</ul>
The <code>filter_placeholder.select</code> setting adds the text to the first select option (default option to show all rows).<br>
<br>
<span class="label label-info">Note:</span> The <code>widget-filter-formatter-jui.js</code> jQuery UI Datepicker Range Selector creates two inputs, so this option then includes two additional settings:<br>
<br>
<pre class="prettyprint lang-js">filter_placeholder : {
search : '',
select : '',
from : '', // datepicker range "from" placeholder
to : '' // datepicker range "to" placeholder
}
</pre><span class="label label-info">Note:</span> The browser must support the <a class="external" href="http://caniuse.com/#feat=input-placeholder">placeholder attribute</a> before it will be visible.
</div>
</td>
<td><a href="example-widget-filter-formatter-1.html">Example</a></td>
</tr>
<tr id="widget-filter-reset">
<td><a href="#" class="permalink">filter_reset</a></td>
<td>String, jQuery object</td>
<td>null</td>
<td>
Filter widget: jQuery selector string of an element used to reset the filters (v2.4; <span class="version updated">v2.16</span>).
<div class="collapsible">
<p>
When this option points to a reset element using a jQuery selector string, it is bound using <a class="external" href="http://api.jquery.com/on/#direct-and-delegated-events">event delegation</a>. So if any additional reset elements, with the same class name, are added to the page dynamically, they will be associated with the same table.<br>
<br>
For example, add this button (<code><button class="reset">Reset</button></code>) to the table header, or anywhere else on the page. That element will be used as a reset for all column and quick search filters (clears all fields):
</p>
Use the <a href="#widget-filter-reset"><code>filter_reset</code></a> option as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_reset : '.reset'
}
});
});</pre>
If this option contains a jQuery object (<span class="version">v2.16</span>), clicking on any of the elements within that jQuery object will trigger a filter reset. If any additional elements with the same selector are added to the page, they will not be dynamically functional.<br>
<br>
If either of these methods do not work as desired, simply trigger a <a href="#filterreset"><code>filterReset</code> event</a> on the table.
</div>
</td>
<td><a href="example-widget-filter-custom.html">Example</a></td>
</tr>
<tr id="widget-filter-resetonesc">
<td><a href="#" class="permalink">filter_resetOnEsc</a></td>
<td>Boolean</td>
<td>true</td>
<td>
Filter widget: when <code>true</code>, normalize pressing escape to clear filter input across browsers (<span class="version">v2.25.2</span>).
<div class="collapsible">
<p>Webkit browsers automatically clear the filter search input when pressing escape, but IE and Firefox do not. Setting this option to <code>true</code>, clears the filter input when the user presses escape.</p>
When this option is set to <code>false</code>, pressing escape inside the search field is ignored.
</div>
</td>
<td></td>
</tr>
<tr id="widget-filter-savefilters">
<td><a href="#" class="permalink">filter_saveFilters</a></td>
<td>Boolean</td>
<td>false</td>
<td>
Filter widget: If the storage utility is available (included with <code>jquery.tablesorter.widgets.js</code> file, the last applied filter is saved to storage (<span class="version">v2.14</span>).
<div class="collapsible">
<br>
Filters saved to local storage (or cookies) will override any default filters within the header data-attribute (set by the <a href="#widget-filter-defaultattrib"><code>filter_defaultAttrib</code> option</a>) and be available to the pager before any ajax calls are made.<br>
<br>
To bypass this behavior, clear out the saved filters as follows:
<pre class="prettyprint lang-js">$.tablesorter.storage( $('table'), 'tablesorter-filters', '' );</pre>
</div>
</td>
<td><a href="example-widget-filter-custom.html">Example</a></td>
</tr>
<tr id="widget-filter-searchdelay">
<td><a href="#" class="permalink">filter_searchDelay</a></td>
<td>Numeric</td>
<td>300</td>
<td>
Filter widget: Set this option to the number of milliseconds to delay the search. (v2.3.4).
<div class="collapsible">
<br>
Use the <a href="#widget-filter-searchdelay"><code>filter_searchDelay</code></a> option as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_searchDelay : 500
}
});
});</pre>
If you want to want to initialize the filter without user input, target any one of the filters and trigger a "search".
<pre class="prettyprint lang-js">// target the first filter input
// this method will begin the search after the searchDelay time
$('input.tablesorter-filter:eq(0)').trigger('search');
// this method will begin the search immediately
$('input.tablesorter-filter:eq(0)').trigger('search', false);</pre>
In tablesorter v2.4+, the trigger can be applied directly to the table:
<pre class="prettyprint lang-js">// refresh the widget filter; no delay
$('table').trigger('search', false);</pre></div>
</td>
<td></td>
</tr>
<tr id="widget-filter-searchfiltered">
<td><a href="#" class="permalink">filter_searchFiltered</a></td>
<td>Boolean</td>
<td>true</td>
<td>
Filter widget: Set this option to allow searching through already filtered rows (in special conditions); this will speed up searching in large tables (<span class="version">v2.17.4</span>).
<div class="collapsible">
<br>
To better explain this, lets do it by example. Lets say you have a column of color names and you enter "light" and results like "light blue" and "light grey" show up.<br>
<br>
When you press the space bar, a space is added, and instead of searching though all of the colors again, the filter widget only searches through the already filtered results that started with "light". This can substantially speed up searching, especially in large tables.<br>
<br>
But, there are some special circumstances which would make this method return incorrect results. So, this option was added to allow you to disable this feature in case one of these following conditions doesn't cover your need; but still, please report any issues!<br>
<br>
The search through filtered results <em>only occurs</em> if the following conditions are met:
<ul>
<li>The last search (for all columns) was not completely empty - all rows will be searched anyway.</li>
<li>If there were no changes to the search from the beginning of the search string (changing the above search to "bright" will force a new search of all rows).</li>
<li>If the search does not contain a logical or (<code> or </code> or <code>|</code>), or a range delimiter (<code> - </code> or <code> to </code>) within the search query.</li>
<li>If the search is not looking for an exact match (<code>"</code> or <code>=</code>) or a logical not search (<code>!</code>).</li>
<li>Or, if the search is using a select dropdown without a "filter-match" class name (looking for an exact match).</li>
<li>If the search does not contain an operator greater than or equal to a negative number (<code>>=-10</code>) or less than or equal to a positive number (<code><=10</code>).</li>
<li>And lastly, only search filtered rows if all rows are not hidden.</li>
</ul>
If the <code>debug</code> option is set to <code>true</code>, then a message will appear while filtering stating the specific number of rows, or "all" rows, that are being searched.<br>
<br>
Use the <a href="#widget-filter-searchfiltered"><code>filter_searchFiltered</code></a> option as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_searchFiltered : false
}
});
});</pre></div>
</td>
<td><a href="example-widget-filter-custom.html#custom_filter_function">Example</a></td>
</tr>
<tr id="widget-filter-selectsource">
<td><a href="#" class="permalink">filter_selectSource</a></td>
<td>Function</td>
<td>null</td>
<td>
Filter widget: Include a function to return an array of values to be added to the column filter select (<span class="version">v2.16.0</span>; <span class="version updated">v2.28.12</span>).
<div class="collapsible">
<br>
In <span class="version updated">v2.24.4</span>, this option will now accept an array of objects which can contain extra information for each option. Here is an example modified from the <a href="example-widget-filter-selectmenu.html">filter selectmenu demo</a>:
<pre class="prettyprint lang-js">filter_selectSource : {
0 : [
{ value : '/\\.js$/', 'data-class' : 'ui-icon-script', text : 'javascript' },
{ value : '/\\.(jpg|png|gif)$/', 'data-class' : 'ui-icon-image', text : 'Image' },
// plain strings are also acceptable - the string is added to both the text & value attribute
'foobar',
{ value : '.css', 'data-class' : 'ui-icon-note', text : 'CSS' },
{ value : '.html', 'data-class' : 'ui-icon-document', text : 'HTML page' },
{ value : '/\\.(json|txt|md)$/', 'data-class' : 'ui-icon-help', text : 'Misc' },
]
}</pre>
<ul>
<li>Each object entry <em>must</em> include a <code>text</code> property, or it will get ignored.</li>
<li>If no <code>value</code> property is set, the option value will be equal to the <code>text</code> (IE requires a value defined for every option).</li>
<li>Plain strings are still allowed within the array. If included, both the option text & value attribute will contain the string.</li>
<li><span class="label warning">*NOTE*</span> when returning an array containing objects, the options will not be reduced to obtain unique selections.</li>
<li><span class="label warning">*NOTE*</span> because this example is providing a fixed select option source, it can not support "filter-onlyAvail" (only show available options after filtering).</li>
</ul>
<p>
In <span class="version updated">v2.28.12</span>, return <code>null</code> from a <code>filter_selectSource</code> function to prevent updates to the select options. Useful if you are updating the select options from outside of tablesorter.
<pre class="prettyprint lang-js">filter_selectSource : {
".filter-select" : function() { return null; }
}</pre>
</p>
<p>
In <span class="version updated">v2.27.7</span>, an option to have a descending sort applied to this data can be done by adding a <code>"filter-select-sort-desc"</code> to the header cell. Adding a <code>"filter-select-nosort"</code> class name to a header to prevent sorting has been available since v2.16.3.
</p>
<p>
In <span class="version updated">v2.21.5</span>, this option will now override the <code>filter_function</code> options (<em>so you need to add them back!</em>), allowing the addition of custom select options and still maintain basic filtering action - see <a href="http://jsfiddle.net/Mottie/856bzzeL/117/">this demo</a> (<a class="external" href="http://stackoverflow.com/a/29506523/145346">ref</a>).
</p>
In <span class="version updated">v2.17.0</span>, the <code>filter_selectSource</code> column can also be referenced by using a jQuery selector (e.g. class name or ID) that points to a table <em>header</em> cell.<br>
<pre class="prettyprint lang-js">filter_selectSource : {
".model-number" : [ "abc", "def", "ghi", "xyz" ]
}</pre>
<span class="label label-warning">Warning</span> What <em>won't work</em> is if you try to target the header using a filtering selector that uses an index, e.g. <code>"th:eq()"</code>, <code>":gt()"</code>, <code>":lt()"</code>, <code>":first"</code>, <code>":last"</code>, <code>":even"</code> or <code>":odd"</code>, <code>":first-child"</code>, <code>":last-child"</code>, <code>":nth-child()"</code>, <code>":nth-last-child()"</code>, etc.<br>
<br>
A column will have a filter select dropdown when a "filter-select" class name is added to the header cell, or if the <a href="#widget-filter-functions"><code>filter_functions</code></a> column value is set to <code>true</code><br>
<br>
This option allows using an alternate source, or customizing options of the filter select dropdown. This option can be set as follows:
<ul>
<li><code>null</code> - this value will set the default behavior and return all table cell values from the current column.</li>
<li>An overall function - when this option is a function, it will be used for all filter selects in the table.
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_selectSource : function(table, column, onlyAvail) {
// get an array of all table cell contents for a table column
var array = $.tablesorter.filter.getOptions(table, column, onlyAvail);
// manipulate the array as desired, then return it
return array;
}
}
});
});</pre>
</li>
<li>An object containing column keys set with a function - when the option is set in this manner, a function can be applied to a specific column.
<p>This example was updated in <span class="version">v2.23.4</span> to use the <code>buildSelect</code> function directly (<a href="https://github.com/Mottie/tablesorter/issues/1010">ref</a>)</p>
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_selectSource : {
0 : function(table, column, onlyAvail) {
// call ajax after tablesorter has initialized; this prevents
// multiple ajax calls during initialization
if (table.hasInitialized) {
$.getJSON('ajax/options.json', function(data) {
// return false if there is a problem and the select
// will display the original defaults
var result = data.hasOwnProperty('options') ? data.options : false;
// if not already done on the server-side & you want to sort & remove duplicates
// from the results, use the processOptions function (added 2.23.4)
result = $.tablesorter.filter.processOptions( table, column, result );
// call the buildSelect function; pass `true` to replace the contents of the select
$.tablesorter.filter.buildSelect( table, column, result, true, onlyAvail );
});
}
return false;
}
}
}
});
});</pre>
</li>
</ul>
The function uses the following parameters:
<ul>
<li><code>table</code> - table DOM element</li>
<li><code>column</code> - zero-based index of the column with a filter select</li>
<li><code>onlyAvail</code> - boolean indicating if the returned options should only be from available (non-filtered) rows.</li>
</ul>
<span class="label label-info">Important</span> Return an array of values which will be added to the filter select dropdown. This array will automatically be stripped of any duplicate values and sorted alphanumerically before being added to the select. If for some reason the custom <code>filter_selectSource</code> function does not obtain the desired array of values, return <code>false</code> and the original method of obtaining column cell content will be used.
</div>
</td>
<td><a href="example-widget-filter-formatter-select2.html">1</a> <a href="example-widget-filter-selectmenu.html">2</a></td>
</tr>
<tr id="widget-filter-selectsource-separator">
<td><a href="#" class="permalink">filter_selectSourceSeparator</a></td>
<td>String</td>
<td>'|'</td>
<td>
Filter widget: Set this option to be any separator (<span class="version">v2.17.6</span>) that is to be used within the <code>filter_selectSource</code> returned array.
<div class="collapsible">
<br>
Use the <a href="#widget-filter-selectsource-separator"><code>filter_selectSourceSeparator</code></a> option as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_selectSource : {
0 : [ 'en|English', 'fr|French', 'de|German' ]
},
// filter_selectSource array text left of the separator is added to the option value, right into the option text
filter_selectSourceSeparator : '|'
}
});
});</pre>Results in this HTML:
<pre class="prettyprint lang-html"><select>
<option value=""></option>
<option value="en">English</option>
<option value="fr">French</option>
<option value="de">German</option>
</select></pre>This also works for the <code>filter_functions</code>
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions: {
filter_functions: {
// Add these options to the select dropdown (regex example)
1 : {
"<10|Less than 10" : function(e, n, f, i, $r, c, data) { return n < 10; },
"10 - 100|Between 10 & 100" : function(e, n, f, i, $r, c, data) { return n >= 10 && n <=100; },
">100|Greater than 100" : function(e, n, f, i, $r, c, data) { return n > 100; }
}
},
// filter_selectSource array text left of the separator is added to the option value, right into the option text
filter_selectSourceSeparator : '|'
}
});
});</pre>
Results in this HTML (this adds a <code>data-function-name</code> attribute to keep a reference to the associated <code>filter_functions</code>.
<pre class="prettyprint lang-html"><select>
<option value=""></option>
<option data-function-name="&lt;10|Less than 10" value="&lt;10">Less than 10</option>
<option data-function-name="10 - 100|Between 10 &amp; 100" value="10 - 100">Between 10 & 100</option>
<option data-function-name="&gt;100|Greater than 100" value="&gt;100">Greater than 100</option>
</select></pre>
</div>
</td>
<td></td>
</tr>
<tr id="widget-filter-serversidefiltering">
<td><a href="#" class="permalink">filter_serversideFiltering</a></td>
<td>Boolean</td>
<td>false</td>
<td>
Filter widget: Set this option to <code>true</code> if filtering is performed on the server-side (v2.5.3).
<div class="collapsible">
<br>
Use the <a href="#widget-filter-serversidefiltering"><code>filter_serversideFiltering</code></a> option as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_serversideFiltering : true
}
});
});</pre></div>
</td>
<td></td>
</tr>
<tr id="widget-filter-startswith">
<td><a href="#" class="permalink">filter_startsWith</a></td>
<td>Boolean</td>
<td>false</td>
<td>
Filter widget: Set this option to <code>true</code> to use the filter to find text from the start of the column, so typing in "a" will find "albert" but not "frank", both have a's. (v2.1).
<div class="collapsible">
<br>
Use the <a href="#widget-filter-startswith"><code>filter_startsWith</code></a> option as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_startsWith : true
}
});
});</pre></div>
</td>
<td><a href="example-widget-filter.html">Example</a></td>
</tr>
<tr id="widget-filter-useParsedData">
<td><a href="#" class="permalink">filter_useParsedData</a></td>
<td>Boolean</td>
<td>false</td>
<td>
Filter widget: If <code>true</code>, ALL filter searches will only use parsed data (v2.4).
<div class="collapsible">
<br>
Use the <a href="#widget-filter-useParsedData"><code>filter_useParsedData</code></a> option as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_useParsedData : false
}
});
});</pre>
<ul>
<li>To only use parsed data in specific columns, set this option to <code>false</code> and use any of the following (they all do the same thing), set in order of priority:
<ul>
<li>jQuery data <code>data-filter="parsed"</code>.</li>
<li>metadata <code>class="{ filter: 'parsed'}"</code>. This requires the metadata plugin.</li>
<li>headers option <code>headers : { 0 : { filter : 'parsed' } }</code>.</li>
<li>header class name <code>class="filter-parsed"</code>.</li>
</ul>
</li>
<li>Remember that parsed data most likely doesn't match the actual table cell text, <code>20%</code> becomes <code>20</code> and <code>Jan 1, 2013 12:01 AM</code> becomes <code>1357020060000</code>.</li>
</ul>
</div>
</td>
<td></td>
</tr>
<tr id="widget-filter-defaultattrib">
<td><a href="#" class="permalink">filter_defaultAttrib</a></td>
<td>String</td>
<td>"data-value"</td>
<td>
Filter widget: This option contains the name of the data-attribute which contains the default (starting) filter value (<span class="version">v2.10.8</span>).
<div class="collapsible">
<br>
Use the <a href="#widget-filter-defaultattrib"><code>filter_defaultAttrib</code></a> option as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_defaultAttrib : 'data-value'
}
});
});</pre>Then add the default filter value to the table header as follows:<pre class="prettyprint lang-html"><th data-value="<30">Age</th></pre></div>
</td>
<td><a href="example-widget-filter-custom.html">Example</a></td>
</tr>
<tr id="widget-sticky-headers">
<td><a href="#" class="permalink">stickyHeaders</a></td>
<td>String</td>
<td>""</td>
<td>Sticky Headers widget: This additional CSS class applied to the sticky header row (<span class="version updated">v2.11</span>).
<div class="collapsible"><br>
Changed to empty string in v2.11, as the <code>"tablesorter-stickyHeader"</code> class will always be added to the sticky header row; this option now contains any additional class names to add.
<p>Previously, this option contained the class name to be applied to the sticky header row (tr) (v2.1).</p>
Use the <a href="#widget-sticky-headers"><code>"stickyHeaders"</code></a> option to add an extra css class name as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["stickyHeaders"],
widgetOptions : {
// css class name applied to the sticky header
stickyHeaders : "tablesorter-stickyHeader"
}
});
});</pre></div>
</td>
<td><a href="example-widget-sticky-header.html">Example</a></td>
</tr>
<tr id="widget-sticky-headers-cloneid">
<td><a href="#" class="permalink">stickyHeaders_cloneId</a></td>
<td>String</td>
<td>"-sticky"</td>
<td>
Sticky Headers widget: If the table has an ID defined, the suffix from this option will be added to the ID in the cloned sticky table (<span class="version">v2.9</span>).
<div class="collapsible">
<br>
So if your table ID is <code>"gummy"</code>, then the cloned sticky table id becomes <code>"gummy-sticky"</code><br>
<br>
Use the <a href="#widget-sticky-headers-cloneid"><code>"stickyHeaders_cloneId"</code></a> option to change the cloned table id as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["stickyHeaders"],
widgetOptions : {
// cloned table id suffix
stickyHeaders_cloneId : "-clone"
}
});
});</pre></div>
</td>
<td></td>
</tr>
<tr id="widget-sticky-headers-include-caption">
<td><a href="#" class="permalink">stickyHeaders_includeCaption</a></td>
<td>Boolean</td>
<td>true</td>
<td>
Sticky Headers widget: If this option is <code>false</code> and a caption exists, it will not be included in the sticky header (<span class="version">v2.10.8</span>).
<div class="collapsible">
<br>
Use the <a href="#widget-sticky-headers-include-caption"><code>stickyHeaders_includeCaption</code></a> option as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["stickyHeaders"],
widgetOptions : {
// cloned table id suffix
stickyHeaders_includeCaption : false
}
});
});</pre></div>
</td>
<td><a href="example-widget-sticky-header.html">Example</a></td>
</tr>
<tr id="widget-sticky-headers-appendto">
<td><a href="#" class="permalink">stickyHeaders_appendTo</a></td>
<td>String, jQuery Object</td>
<td>null</td>
<td>
Sticky Headers widget: jQuery selector or object to physically attach the sticky headers (<span class="version">v2.27.0</span>).
<div class="collapsible">
<p>
<span class="label label-warning">Note</span> Appending the sticky headers to an element that does not have the same dimensions (width) as the table wrapper will produce a sticky header that does not match the table size!
</p>
Use the <a href="#widget-sticky-headers-appendto"><code>stickyHeaders_appendTo</code></a> option as follows:<br>
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["stickyHeaders"],
widgetOptions : {
// Where to attach the stickyHeaders
stickyHeaders_appendTo : '.wrapper' // $('.wrapper') jQuery object can also be used
}
});
});</pre></div>
</td>
<td></td>
</tr>
<tr id="widget-sticky-headers-attachto">
<td><a href="#" class="permalink">stickyHeaders_attachTo</a></td>
<td>String, jQuery Object</td>
<td>null</td>
<td>
Sticky Headers widget: points to the table wrapper to stick the headers to while scrolling. Use this option to point to their needs (<span class="version">v2.14.4</span>).
<div class="collapsible">
<br>
Use the <a href="#widget-sticky-headers-attachto"><code>stickyHeaders_attachTo</code></a> option as follows:<br>
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["stickyHeaders"],
widgetOptions : {
// Where to attach the stickyHeaders
stickyHeaders_attachTo : '.wrapper' // $('.wrapper') jQuery object can also be used
}
});
});</pre></div>
</td>
<td><a href="example-widget-sticky-header.html">Example</a></td>
</tr>
<tr id="widget-sticky-headers-xscroll">
<td><a href="#" class="permalink">stickyHeaders_xScroll</a></td>
<td>String, jQuery Object</td>
<td>null</td>
<td>
Sticky Headers widget: points to the element in which to monitor for horizontal scrolling (<span class="version">v2.18.0</span>).
<div class="collapsible">
<br>
If undefined (or <code>null</code>), the window element will be monitored.<br>
<br>
Use the <a href="#widget-sticky-headers-xscroll"><code>stickyHeaders_xScroll</code></a> option as follows:<br>
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["stickyHeaders"],
widgetOptions : {
// jQuery selector or object to monitor horizontal scroll position (defaults: xScroll > attachTo > window)
stickyHeaders_xScroll : '.wrapper' // $('.wrapper') jQuery object can also be used
}
});
});</pre></div>
</td>
<td><a href="example-widget-sticky-header.html">Example</a></td>
</tr>
<tr id="widget-sticky-headers-yscroll">
<td><a href="#" class="permalink">stickyHeaders_yScroll</a></td>
<td>String, jQuery Object</td>
<td>null</td>
<td>
Sticky Headers widget: points to the element in which to monitor for vertical scrolling (<span class="version">v2.18.0</span>).
<div class="collapsible">
<br>
If undefined (or <code>null</code>), the window element will be monitored.<br>
<br>
Use the <a href="#widget-sticky-headers-yscroll"><code>stickyHeaders_yScroll</code></a> option as follows:<br>
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["stickyHeaders"],
widgetOptions : {
// jQuery selector or object to monitor vertical scroll position (defaults: yScroll > attachTo > window)
stickyHeaders_yScroll : '.wrapper' // $('.wrapper') jQuery object can also be used
}
});
});</pre></div>
</td>
<td><a href="example-widget-sticky-header.html">Example</a></td>
</tr>
<tr id="widget-sticky-headers-offset">
<td><a href="#" class="permalink">stickyHeaders_offset</a></td>
<td>Multiple</td>
<td>0</td>
<td>
Sticky Headers widget: Set the sticky header offset from the top as a <em>Number</em> or jQuery selector <em>string</em> or <em>object</em> (<span class="version">v2.10</span>).
<div class="collapsible">
<br>
If the page includes a fixed navigation bar at the top, like Bootstrap, set <a href="#widget-sticky-headers-offset"><code>"stickyHeaders_offset"</code></a> option to offset the sticky table header to be below the fixed navigation by setting this option using any of the following examples:<br>
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["stickyHeaders"],
widgetOptions : {
// apply sticky header top 30px below the top of the browser window
stickyHeaders_offset : 30
}
});
});</pre>or
<pre class="prettyprint lang-js">stickyHeaders_offset : '.navbar-fixed-top' // jQuery selector string</pre>or
<pre class="prettyprint lang-js">stickyHeaders_offset : $('.navbar-fixed-top') // jQuery object</pre></div>
</td>
<td></td>
</tr>
<tr id="widget-sticky-headers-filtered-to-top">
<td><a href="#" class="permalink">stickyHeaders_filteredToTop</a></td>
<td>Boolean</td>
<td>true</td>
<td>
Sticky Headers widget: Scroll table top into view after filtering (<span class="version">v2.16.2</span>).
<div class="collapsible">
<br>
When a user searches the table using the sticky header filter row the results may reduce the number of rows so that the table would scroll up out of the viewport. So, this option scrolls the table top into view and moves the filter focus to the same input in the original header, instead of the sticky header input.<br>
<br>
Set this option to <code>false</code> to prevent the page scroll after filtering the table.
</div>
</td>
<td></td>
</tr>
<tr id="widget-sticky-headers-addresizeevent">
<td><a href="#" class="permalink">stickyHeaders_addResizeEvent</a></td>
<td>Boolean</td>
<td>true</td>
<td>
Sticky Headers widget: If <code>true</code>, sticky table headers will resize automatically when content is added to or removed from the table headers (<span class="version">v2.10</span>).
<div class="collapsible">
<br>
While this option is <code>true</code>, a timer is initialized to check the width of every header cell every 1/4 second. If this causes lag, or any other problems, set this option to <code>false</code>.
When this option is <code>false</code>, sticky table headers are unable to detect and match the width of the original table headers when content is added or removed.<br>
<br>
Use the <a href="#widget-sticky-headers-addresizeevent"><code>"stickyHeaders_addResizeEvent"</code></a> option as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["resizable"],
widgetOptions : {
// add header resize detection
stickyHeaders_addResizeEvent : true
}
});
});</pre>When the browser window is resized, the headers (original and sticky) will resize automatically no matter the value of this option.
</div>
</td>
<td></td>
</tr>
<tr id="widget-sticky-headers-zindex">
<td><a href="#" class="permalink">stickyHeaders_zIndex</a></td>
<td>Numeric</td>
<td>2</td>
<td>
Sticky Headers widget: The zIndex added to the stickyHeaders. This option allows the user to adjust the value to their needs (<span class="version">v2.11</span>).
<div class="collapsible">
<br>
Use the <a href="#widget-sticky-headers-zindex"><code>stickyHeaders_zIndex</code></a> option as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["stickyHeaders"],
widgetOptions : {
// The zIndex of the stickyHeaders, allows the user to adjust this to their needs
stickyHeaders_zIndex : 100
}
});
});</pre></div>
</td>
<td></td>
</tr>
<tr id="widget-resizable">
<td><a href="#" class="permalink">resizable</a></td>
<td>Boolean</td>
<td>true</td>
<td>
Resizable widget: If this option is set to <code>false</code>, resized column widths will not be saved. Previous saved values will be restored on page reload (v2.4).
<div class="collapsible">
<br>
Use the <a href="#widget-resizable"><code>"resizable"</code></a> option to not save the resized widths:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["resizable"],
widgetOptions : {
// css class name applied to the sticky header
resizable : false
}
});
});</pre></div>
</td>
<td><a href="example-widget-resizable.html">Example</a></td>
</tr>
<tr id="widget-resizable-addlastcolumn">
<td><a href="#" class="permalink">resizable_addLastColumn</a></td>
<td>Boolean</td>
<td>false</td>
<td>
Resizable widget: If this option is set to <code>true</code>, a resizing anchor will be included in the last column of the table (<span class="version">v2.8.3</span>).
<div class="collapsible">
<br>
If an anchor was included and the table is full width, the column would resize in the opposite direction which my not be intuitive to the user. So set this option as desired, but please be mindful of the user experience.<br>
<br>
Use the <a href="#widget-resizable-addlastcolumn"><code>"resizable_addLastColumn"</code></a> option to include the last column resizer as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["resizable"],
widgetOptions : {
// css class name applied to the sticky header
resizable_addlastcolumn : true
}
});
});</pre></div>
</td>
<td><a href="example-widget-resizable.html">Example</a></td>
</tr>
<tr id="widget-resizable-includefooter">
<td><a href="#" class="permalink">resizable_includeFooter</a></td>
<td>Boolean</td>
<td>true</td>
<td>Resizable widget: If this option is set to <code>true</code>, the resizable handle will extend into the table footer (<span class="version">v2.28.8</span>).
<div class="collapsible">
<p>When <code>true</code>, this option includes the entire height of the table footer. If the table does not include a footer, the resize handle will stop at the last row.</p>
<p>If <code>false</code>, the resizable handle will not extend into the table footer.</p>
</div>
</td>
<td></td>
</tr>
<tr id="widget-resizable-widths">
<td><a href="#" class="permalink">resizable_widths</a></td>
<td>Array</td>
<td>[]</td>
<td>
Resizable widget: Set this option to the starting & reset header widths (<span class="version">v2.15.12</span>).
<div class="collapsible">
<br>
Use the <a href="#widget-resizable-widths"><code>"resizable_widths"</code></a> option as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["resizable"],
widgetOptions : {
// headers widths applied at initialization & resizable reset
// this setting includes any non-resizable cells (resizable-false)
resizable_widths : [ '10%', '10%', '50px' ]
}
});
});</pre></div>
</td>
<td><a href="example-widget-resizable.html">Example</a></td>
</tr>
<tr id="widget-resizable-throttle">
<td><a href="#" class="permalink">resizable_throttle</a></td>
<td>Boolean</td>
<td>false</td>
<td>
Resizable widget: Set this option to throttle the resizable events (<span class="version">v2.17.4</span>).
<div class="collapsible">
<br>
When <code>false</code> throttling of the mousemove (resizing) event is not applied.<br>
<br>
Set this option to either <code>true</code> for a default 5 millisecond delay, or set it to any number less than 10 to adjust the throttling delay that is applied to the mousemove/resizing event.<br>
<br>
Use the <a href="#widget-resizable-throttle"><code>"resizable_throttle"</code></a> option as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["resizable"],
widgetOptions : {
// set to true for a default 5ms throttling delay
// or set to a number < 10 (more than that makes the resizing adjustment unusable
resizable_throttle : true
}
});
});</pre></div>
</td>
<td></td>
</tr>
<tr id="widget-resizable-target-last">
<td><a href="#" class="permalink">resizable_targetLast</a></td>
<td>Boolean</td>
<td>false</td>
<td>
Resizable widget: When <code>true</code>, the last column will be targeted for resizing (<span class="version">v2.21.3</span>).
<div class="collapsible">
<p>When <code>true</code>, resizing a column will change the size of the selected column, and the last column, not the selected column's neighbor.</p>
<p>When <code>false</code>, resizing a column will move the column border between it's neighbors.</p>
<p>Also, in a <em>full width table</em>, if this option is <code>false</code>, the same behavior as when this option is <code>true</code> can be seen when resizing a column while holding down the <kbd>Shift</kbd> key on the keyboard - the last column is resized.</p>
</div>
</td>
<td></td>
</tr>
<tr id="widget-savesort">
<td><a href="#" class="permalink">saveSort</a></td>
<td>Boolean</td>
<td>true</td>
<td>
SaveSort widget: If this option is set to <code>false</code>, new sorts will not be saved. Any previous saved sort will be restored on page reload (v2.4).
<div class="collapsible">
<br>
Use the <a href="#widget-savesort"><code>"saveSort"</code></a> option to not save the current sort:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["saveSort"],
widgetOptions : {
// if false, the sort will not be saved for next page reload
saveSort : false
}
});
});</pre></div>
</td>
<td><a href="example-widget-savesort.html">Example</a></td>
</tr>
<tr id="widget-storage-storage-type">
<td><a href="#" class="permalink">storage_storageType</a></td>
<td>String</td>
<td>""</td>
<td>
Storage widget: Set this option to the first letter of the desired storage type (<span class="version">v2.28.8</span>).
<div class="collapsible">
<p>If <em>any</em> value is set in this option, the deprecated <a href="#widget-storage-use-session-storage"><code>"storage_useSessionStorage"</code></a> is completely ignored.</p>
<ul>
<li>When set to <code>"s"</code> (session), all saved variables for the table use <code>sessionStorage</code>. This means once the user closes the browser, all saved variables are lost.</li>
<li>When set to <code>"c"</code> (cookie), all saved variables for the table will use cookies.</li>
<li>Any other setting will switch to using the default <code>localStorage</code> type.</li>
</ul>
Use the <a href="#widget-storage-storage-type"><code>"storage_storageType"</code></a> option as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["saveSort"],
widgetOptions : {
// This sets session storage; only the first letter is required
storage_storageType : "session"
}
});
});</pre></div>
</td>
<td></td>
</tr>
<tr id="widget-storage-use-session-storage">
<td><a href="#" class="permalink alert">storage_useSessionStorage</a></td>
<td>Boolean</td>
<td>false</td>
<td>
Storage widget: This option was <span class="label label-danger">deprecated</span> in <span class="version updated">v2.28.8</span>.
<div class="collapsible">
<p>In <span class="version">v2.28.8</span>, this option is replaced by the <a href="#widget-storage-storage-type"><code>"storage_storageType"</code></a> option and will be completely ignored if that option has <em>any</em> setting.</p>
<p>If this option is set to <code>false</code>, all saved variables for the table will be within local storage (<span class="version">v2.21.3</span>).</p>
<p>If <code>true</code>, all saved variables for the table will be within the session storage. This means once the user closes the browser, all saved variables are lost.</p>
Use the <a href="#widget-storage-use-session-storage"><code>"storage_useSessionStorage"</code></a> option to switch to session storage as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["saveSort"],
widgetOptions : {
// if false, saved variables will be saved in local storage
storage_useSessionStorage : true
}
});
});</pre></div>
</td>
<td><a href="example-widget-resizable.html">Example</a></td>
</tr>
<tr id="widget-storage-table-id">
<td><a href="#" class="permalink">storage_tableId</a></td>
<td>String</td>
<td>""</td>
<td>
Storage widget: This option allows setting an alternate table id so multiple tables on a page have the settings grouped together
<div class="collapsible">
<p>When grouping together multiple tables, setting the variable on one table will not cause the setting to modify a second table, the change will only be apparent on page reload.</p>
<p>If this option is not defined, the actual table id will be used (which isn't conducive to applying to multiple tables!)</p>
<p>A more detailed list of the table id priority settings can be found in the <a href="#function-storage"><code>$.tablesorter.storage</code></a> function description.</p>
</div>
</td>
<td></td>
</tr>
<tr id="widget-storage-group">
<td><a href="#" class="permalink">storage_group</a></td>
<td>String</td>
<td>""</td>
<td>
Storage widget: Set a table (data) attribute to use to obtain a table id, which allows grouping multiple tables on one page together - they share a common saved setting.
<div class="collapsible">
<p>If a value is set in this option, the storage widget looks in that defined table data-attribute for a table id.</p>
<p>If this option is not defined, then the default data-attribute for the table becomes <code>"data-table-group"</code>.</p>
<p>The value in the data-attribute sets a table id, if not found, the storage widget then looks for an id in the <a href="#widget-storage-table-id"><code>storage_tableId</code></a> option.</p>
</div>
</td>
<td></td>
</tr>
<tr id="widget-storage-fixed-url">
<td><a href="#" class="permalink">storage_fixedUrl</a></td>
<td>String</td>
<td>""</td>
<td>
Storage widget: This option allows setting an alternate table url so that tables on multiple pages will have their settings grouped together
<div class="collapsible">
<p>This option replaces and will override the now deprecated <code>config.fixedUrl</code> option.</p>
<p>If there is a value within the table's "data-table-page" (set by the <code>storage_page</code> option), it will override this setting.</p>
<p>A more detailed list of the table url priority settings can be found in the <a href="#function-storage"><code>$.tablesorter.storage</code></a> function description.</p>
</div>
</td>
<td></td>
</tr>
<tr id="widget-storage-page">
<td><a href="#" class="permalink">storage_page</a></td>
<td>String</td>
<td>""</td>
<td>
Storage widget: Set a table (data) attribute to use to obtain a table url, which allows grouping tables across multiple pages together - they share a common saved setting.
<div class="collapsible">
<p>If a value is set in this option, the storage widget looks in that defined table data-attribute for a table url.</p>
<p>If this option is not defined, then the default data-attribute for the table becomes <code>"data-table-page"</code>.</p>
<p>The value in the data-attribute sets a table url, if not found, the storage widget then looks for a url in the <a href="#widget-storage-fixed-url"><code>storage_fixedUrl</code></a> option.</p>
</div>
</td>
<td></td>
</tr>
<tr id="widget-zebra">
<td><a href="#" class="permalink">zebra</a></td>
<td>Array</td>
<td>[ "even", "odd" ]</td>
<td>
Zebra widget: When the zebra striping widget is initialized, it automatically applied the default class names of <code>"even"</code> and <code>"odd"</code>. (Modified v2.1).
<div class="collapsible">
<br>
Use the <a href="#widget-zebra"><code>"zebra"</code></a> option to change the theme as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["zebra"], // initialize zebra striping of the table
widgetOptions: {
zebra: [ "normal-row", "alt-row" ]
}
});
});</pre></div>
</td>
<td><a href="example-widget-zebra.html">Example</a></td>
</tr>
</tbody>
<!-- non-sorting tbody -->
<tbody id="pager" class="tablesorter-infoOnly">
<tr><th colspan="5">Pager</th></tr>
</tbody>
<tbody>
<tr id="pager-container">
<td><a href="#" class="permalink">container</a></td>
<td>Object</td>
<td>null</td>
<td>
Target your one or more pager markup blocks by setting this option with a jQuery selector.
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_selectors.container</code>; additionally you can change the class name that is applied to the pager (used within the <code>jquery.tablesorter.pager.css</code> file) by modifying the <code>widgetOption.pager_css.container</code> class name (default is <code>"tablesorter-pager"</code>)<br>
<br>
This is some example pager markup. It <em>should</em> contain all of the controls set by the multiple css-named options:<pre class="prettyprint lang-html">
<div class="pager">
<form>
<img src="first.png" class="first"/>
<img src="prev.png" class="prev"/>
<span class="pagedisplay"></span> <!-- this can be any element, including an input -->
<img src="next.png" class="next"/>
<img src="last.png" class="last"/>
<select class="pagesize">
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="40">40</option>
</select>
<select class="gotoPage" title="Select page number"></select>
</form>
</div></pre><span class="label label-warning">Caution</span> If you use buttons in your pager container, make sure the buttons include a button type (<code><button type="button">Next</button></code>) to prevent form submission and page reloading every time the button is clicked.<br>
<br>Use this option as follows:<pre class="prettyprint lang-js">$(function() {
$("table")
.tablesorter()
.tablesorterPager({
container: $(".pager")
});
});</pre></div>
</td>
<td><a href="example-pager.html">Example</a></td>
</tr>
<tr id="pager-ajaxurl">
<td><a href="#" class="permalink">ajaxUrl</a></td>
<td>String</td>
<td>null</td>
<td>
Set this option to include a url template to use so that the pager plugin can interact with your database (v2.1; <span class="version updated">v2.9</span>).
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_ajaxUrl</code><br>
<br>
The tags within the <code>ajaxUrl</code> string are optional. If do not want the user to change the page size, then you only need to include the page in this string:
<pre class="prettyprint lang-js">ajaxUrl: "http://mydatabase.com?start={page}"</pre>
If you need to send your server a page offset (actual starting record number), then you'll need to use the <a href="#pager-customajaxurl"><code>customAjaxUrl</code> option</a>.<br>
<br>
Here is an example of how to include the option, it should <em>always</em> be paired with an <code>ajaxProcessing</code> function:
<pre class="prettyprint lang-js">$(function() {
$("table")
.tablesorter()
.tablesorterPager({
ajaxUrl: "http://mydatabase.com?page={page}&size={size}&{sortList:col}&{filterList:fcol}",
ajaxProcessing: function(data, table, xhr) {
// do something with the ajax data
return [ formatted_data, total_rows ];
}
});
});</pre>The <code>ajaxUrl</code> template replaces the following tags with values from the tablesorter plugin and pager addon:
<br>
<table class="info">
<thead>
<tr><td>Tag</td><td>Replaced with</td></tr>
</thead>
<tbody>
<tr><td><code>{page}</code></td><td>Zero-based index of the current pager page</td></tr>
<tr><td><code>{page+1}</code></td><td>One-based index of the current pager page (replace "+1" with any number) (e.g. <code>{page+3}</code>) (<span class="version">v2.9</span>).</td></tr>
<tr><td><code>{size}</code></td><td>Number of rows showing, or number of rows to get from the server</td></tr>
<tr>
<td><code>{sortList:col}</code> or <code>{sort:col}</code></td>
<td>Adds the current sort to the ajax url string into a "col" array, so your server-side code knows how to sort the data (v2.4.5).<br>
The <code>col</code> portion of the <code>{sortList:col}</code> tag can be any name string (no spaces) to indicate the name of the variable to apply. So if your current sortList is <code>[[2,0],[3,0]]</code>, it becomes <code>"&sort[2]=0&sort[3]=0"</code> in the url. <code>{sort:col}</code> shortened tag also works (<span class="version">v2.9</span>).
</td>
</tr>
<tr>
<td><code>{filterList:fcol}</code> or <code>{filter:fcol}</code></td>
<td>Adds the value of the current filters to the ajax url string into a "fcol" array, so your server-side code knows how to filter the data (v2.6).<br>
The <code>fcol</code> portion of the <code>{filterList:fcol}</code> tag can be any name string (no spaces) to indicate the name of the variable to apply. So if your current filters are <code>['','Blue',13]</code>, it becomes <code>"&fcol[2]=Blue&fcol[3]=13"</code> in the url. <code>{filter:col}</code> shortened tag also works (<span class="version updated">v2.9</span>).
</td>
</tr>
</tbody>
</table></div>
</td>
<td><a href="example-pager-ajax.html">Example</a></td>
</tr>
<tr id="pager-customajaxurl">
<td><a href="#" class="permalink">customAjaxUrl</a></td>
<td>Function</td>
<td>function(table, url) { return url; }</td>
<td>
This callback function allows you to modify the processed URL as desired (<span class="version">v2.8.1</span>).
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_customAjaxUrl</code><br>
<br>
The <code>customAjaxUrl</code> function has two parameters, the table DOM element and the processed url string (all tags within the <code>ajaxUrl</code> have been replaced with their appropriate values).
<pre class="prettyprint lang-js">$(function() {
$("table")
.tablesorter()
.tablesorterPager({
ajaxUrl: "http://mydatabase.com?page={page}&size={size}&{sortList:col}&{filterList:fcol}",
ajaxProcessing: function(data, table, xhr) {
// do something with the ajax data
return [ formatted_data, total_rows ];
},
// modify the url after all processing has been applied
customAjaxUrl: function(table, url) {
// trigger my custom event
$(table).trigger('changingUrl');
// send the server the current page
return url += '&currntUrl=' + window.location.href;
}
});
});</pre>
In the following example, lets say your server needs a starting and ending record number instead of a page & size parameter. Use this option as follows:
<pre class="prettyprint lang-js">$(function() {
$("table")
.tablesorter()
.tablesorterPager({
ajaxUrl: "http://mydatabase.com?{sortList:col}",
customAjaxUrl: function(table, url) {
var pager = table.config.pager,
start = pager.page * pager.size,
end = start + pager.size;
return url += '&start=' + start + '&end=' + end;
},
ajaxProcessing: function(data, table, xhr) {
// do something with the ajax data
return [ total_rows, data ];
}
});
});</pre>
</div>
</td>
<td><a href="example-pager-ajax.html">Example</a></td>
</tr>
<tr id="pager-ajaxobject">
<td><a href="#" class="permalink">ajaxObject</a></td>
<td>Object</td>
<td>{ dataType: 'json' }</td>
<td>
This option contains the ajax settings for the pager interaction with your database (<span class="version">v2.10</span>).
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_ajaxObject</code><br>
<br>
The <code>ajaxObject</code> is completely customizable, except for the <code>url</code> setting which is processed using the pager's <code>ajaxUrl</code> and <code>customAjaxUrl</code> options. This means you can also add a <code>success</code> callback function which is called after the ajax has rendered.<br>
<br>
Your server does not need to return a JSON format, if you want to return pure HTML, set the dataType to <code>"html"</code> and modify the <code>ajaxProcessing</code> function to instead work with HTML; then return a jQuery object or apply the HTML to the table yourself.<br>
<br>
See all possible settings in the <a class="external" href="http://api.jquery.com/jQuery.ajax/#jQuery-ajax-settings">jQuery.ajax documentation</a>
<pre class="prettyprint lang-js">$(function() {
$("table")
.tablesorter()
.tablesorterPager({
ajaxUrl: "http://mydatabase.com?page={page}&size={size}&{sortList:col}&{filterList:fcol}",
ajaxObject: {
// add more ajax settings here
// see http://api.jquery.com/jQuery.ajax/#jQuery-ajax-settings
dataType: 'json',
type: 'GET'
},
ajaxProcessing: function(data, table, xhr) {
// do something with the ajax data;
return [ total_rows ];
}
});
});</pre></div>
</td>
<td><a href="example-pager-ajax.html">Example</a></td>
</tr>
<tr id="pager-ajaxerror">
<td><a href="#" class="permalink">ajaxError</a></td>
<td>Function</td>
<td>null</td>
<td>
This callback allows you to customize the error message displayed in the <code>thead</code> (<span class="version">v2.23.0</span>; <span class="version updated">v2.23.1</span>).
<div class="collapsible">
<br>
In <span class="version updated">v2.23.1</span>
<ul>
<li>A <code>settings</code> parameter was added <em>before</em> the <code>exception</code> parameter to exactly match the parameters returned by the jQuery <a class="external" href="http://api.jquery.com/ajaxError/">.ajaxError()</a> method.</li>
<li>This function is now always called, even if the <code>$.tablesorter.showError</code> function is called by an external function with only a string.</li>
</ul>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_ajaxError</code><br>
<br>
When there is an ajax error, the <a href="#function-showError"><code>$.tablesorter.showError</code></a> function is called. In <span class="version">v2.23.0</span>, that function now checks this callback to allow adding a custom error message.<br>
<br>
Use it as follows:
<pre class="prettyprint lang-js">$(function() {
$("table")
.tablesorter()
.tablesorterPager({
ajaxError: function( config, xhr, settings, exception ) {
// returning false will abort the error message
// the code below is the default behavior when this callback is set to `null`
return
xhr.status === 0 ? 'Not connected, verify Network' :
xhr.status === 404 ? 'Requested page not found [404]' :
xhr.status === 500 ? 'Internal Server Error [500]' :
exception === 'parsererror' ? 'Requested JSON parse failed' :
exception === 'timeout' ? 'Time out error' :
exception === 'abort' ? 'Ajax Request aborted' :
'Uncaught error: ' + xhr.statusText + ' [' + xhr.status + ']' );
}
});
});</pre></div>
</td>
<td></td>
</tr>
<tr id="pager-initialrows">
<td><a href="#" class="permalink">initialRows</a></td>
<td>Object</td>
<td>undefined</td>
<td>
When <code>processAjaxOnInit</code> is set to <code>false</code>, set this option to contain the total number of rows and filtered rows to prevent an initial ajax call (<span class="version">v2.25.4</span>).
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_initialRows</code>
<p>Use this option as follows:</p>
<pre class="prettyprint lang-js">$(function() {
$("table")
.tablesorter()
.tablesorterPager({
processAjaxOnInit: false,
initialRows: {
total: 100,
filtered: 100
},
// other ajax settings...
});
});</pre>
</div>
</td>
<td></td>
</tr>
<tr id="pager-processajaxoninit">
<td><a href="#" class="permalink">processAjaxOnInit</a></td>
<td>Boolean</td>
<td>true</td>
<td>
Set this option to <code>false</code> if your table data is preloaded into the table, but you are still using ajax (<span class="version">v2.14.5</span>).
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_processAjaxOnInit</code>
</div>
</td>
<td></td>
</tr>
<tr id="pager-ajaxprocessing">
<td><a href="#" class="permalink">ajaxProcessing</a></td>
<td>Function</td>
<td>function (data) { return data; }</td>
<td>
This function is required to return the ajax data obtained from your server into a useable format for tablesorter to apply to the table (v2.1, <span class="version updated">v2.30.8</span>).
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_ajaxProcessing</code><br>
<br>
This function was created and modified to allow you a great deal of flexibility. The only required information that this function needs to return is an array containing the total number of rows, which is needed to calculate total pages.<br>
<br>
There are numerous examples below. Choosing which one to use is left to you. For more information, please check out related questions on <a class="external" href="http://stackoverflow.com/search?q=%5Btablesorter%5D+ajaxProcessing">Stackoverflow</a>, in particular see <a class="external" href="http://stackoverflow.com/q/16783740/145346">this thread</a> about how to use the different ajax options together.<br>
<br>
In <span class="version">v2.10</span>, the returned rows is now optional. And it can either be an array of arrays or a jQuery object (not attached to the table)<br>
<br>
Process your ajax data so that the following information is returned:<br>
<br>
<div class="accordion">
<h3><a href="#">Object</a></h3>
<div>
After tablesorter <span class="version updated">v2.17.3</span>, this function can include a <code>filteredRows</code> property which will update the internal value and thus show a proper filtered row count, and update the "goto" page drop down selector appropriately.<br>
<br>
After tablesorter <span class="version">v2.11</span>, the <code>ajaxProcessing</code> function can return an object containing these properties, along with any extra properties. These extra properties will be available for use within the pager <code>output</code> string (see more details in <a href="https://github.com/Mottie/tablesorter/issues/326#issuecomment-25326546">issue #326</a>);<br>
<br>
So, lets say the data sent by the server looks like this:
<pre class="prettyprint lang-js">{
"total_rows" : 100,
"filtered_rows" : 75,
"new_headers" : [ "ID", "Name", "Data", "Value" ],
"data" : '<tr><td>a123</td><td>abc</td><td>xyz</td><td>999</td></tr>',
"subject" : "cheese",
"tasty" : "It's delicious!"
}</pre>
This ajaxProcessing function must return an object with "total", "headers" and "rows" properties! As before, "total" is the only required property; if the headers don't need to be changed, don't return a headers array, and if you append the rows to the table yourself within the ajaxProcessing function, you don't need to return a "rows" property.
<pre class="prettyprint lang-js">ajaxProcessing: function(result, table, xhr) {
if (result && result.hasOwnProperty('data')) {
// "total" is a required property!
result.total = result["total_rows"];
// "filteredRows" is optional - in tablesorter v2.17.3, this updates the filter row count internally
// and updates the "goto" page dropdown selector appropriately
result.filteredRows = result["filtered_rows"];
// "headers" is optional. This is not needed if the table headers don't change
result.headers = result["new_headers"];
// "rows" is optional. No need to return this if you process and add the rows to the table yourself
// otherwise, return an array of arrays or jQuery object (shown in this example)
result.rows = $(result.data);
return result;
}
}</pre>
Now in the <a href="#pager-output"><code>output</code></a> string, you can also reference the extra ajax data:
<pre class="prettyprint lang-js">output : '{startRow} to {endRow} of {filteredRows} ({totalRows}) rows about {subject} ({tasty})'</pre>
</div>
<h3><a href="#">Array (total only)</a></h3>
<div>
After tablesorter <span class="version">v2.10</span>, just build the table yourself and return the total number of rows:
<pre class="prettyprint lang-js">ajaxProcessing: function(data, table, xhr) {
if (data && data.hasOwnProperty('rows')) {
var r, row, c, d = data.rows,
// total number of rows (required)
total = data.total_rows,
// all rows: array of arrays; each internal array has the table cell data for that row
rows = '',
// len should match pager set size (c.size)
len = d.length;
// this will depend on how the json is set up - see City0.json
// rows
for ( r=0; r < len; r++ ) {
rows += '<tr class="ajax-row">'; // new row
// cells
for ( c in d[r] ) {
if (typeof(c) === "string") {
rows += '<td>' + d[r][c] + '</td>'; // add each table cell data to row
}
}
rows += '</tr>'; // end new row
}
// find first sortable tbody, then add new rows
table.config.$tbodies.eq(0).html(rows);
// no need to trigger an update method, it's done internally
return [ total ];
}
}</pre>
</div>
<h3><a href="#">Array (rows as jQuery object)</a></h3>
<div>
After tablesorter <span class="version">v2.10</span>, return a jQuery object
<pre class="prettyprint lang-js">ajaxProcessing: function(data, table, xhr) {
if (data && data.hasOwnProperty('rows')) {
var r, row, c, d = data.rows,
// total number of rows (required)
total = data.total_rows,
// array of header names (optional)
headers = data.headers,
// all rows: array of arrays; each internal array has the table cell data for that row
rows = '',
// len should match pager set size (c.size)
len = d.length;
// this will depend on how the json is set up - see City0.json
// rows
for ( r=0; r < len; r++ ) {
rows += '<tr class="ajax-row">'; // new row
// cells
for ( c in d[r] ) {
if (typeof(c) === "string") {
rows += '<td>' + d[r][c] + '</td>'; // add each table cell data to row
}
}
rows += '</tr>'; // end new row
}
// don't attach the $(rows) because it's difficult to tell old from new data
// and no need to trigger an update method, it's done internally
return [ total, $(rows), headers ];
}
}</pre>
Or, if your JSON contains all the rows within a string this method will work:
<pre class="prettyprint lang-js">ajaxProcessing: function(data, table, xhr) {
if (data && data.hasOwnProperty('rows')) {
// data.rows would look something like this
// '<tr><td>r0c0</td><td>r0c1</td></tr><tr><td>r1c0</td><td>r1c1</td></tr>'
return [ data.total, $(data.rows), data.headers ];
}
}</pre>
</div>
<h3><a href="#">Array (rows as an array of arrays)</a></h3>
<div>
After tablesorter v2.1, this function must return an array with values in any of the following orders:
<pre class="prettyprint lang-js">// [ total_rows (number), rows (array of arrays), headers (array; optional) ]
// or [ rows, total_rows, headers ]
// or [ total_rows, $(rows) ]
// or [ total_rows ]
[
100, // total rows
[
[ "row1cell1", "row1cell2", ... "row1cellN" ],
[ "row2cell1", "row2cell2", ... "row2cellN" ],
...
[ "rowNcell1", "rowNcell2", ... "rowNcellN" ]
],
[ "header1", "header2", ... "headerN" ] // optional
]</pre><span class="label label-info">Note</span>: In <span class="version">v2.14.3</span>, the contents of the array can also contain table cell markup (i.e. <code>"<td class='green'>+ 10%</td>"</code>).<br>
<br>
Here is some example JSON (comments added, but not allowed in JSON) which is contained in the <a href="https://github.com/Mottie/tablesorter/blob/master/docs/assets/City0.json">City0.json</a> file:
<pre class="prettyprint lang-js">{
// total rows
"total_rows": 80,
// headers
"cols" : [
"ID", "Name", "Country Code", "District", "Population"
],
// row data...
"rows" : [{
"ID": 1,
"Name": "Kabul",
"CountryCode": "AFG",
"District": "Kabol",
"Population": 1780000
}, {
// row 2, etc...
}]
}</pre>
The above JSON is processed by the following code (this returns an array of array of table rows):
<pre class="prettyprint lang-js">$(function() {
$("table")
.tablesorter()
.tablesorterPager({
ajaxUrl: "http://mydatabase.com?page={page}&size={size}",
ajaxProcessing: function(data, table, xhr) {
if (data && data.hasOwnProperty('rows')) {
var r, row, c, d = data.rows,
// total number of rows (required)
total = data.total_rows,
// array of header names (optional)
headers = data.cols,
// all rows: array of arrays; each internal array has the table cell data for that row
rows = [],
// len should match pager set size (c.size)
len = d.length;
// this will depend on how the json is set up - see City0.json
// rows
for ( r = 0; r < len; r++ ) {
row = []; // new row array
// cells
for ( c in d[r] ) {
if (typeof(c) === "string") {
row.push(d[r][c]); // add each table cell data to row array
}
}
rows.push(row); // add new row array to rows array
}
return [ total, rows, headers ]; // or return [ rows, total, headers ] in v2.9+
}
}
});
});</pre>
</div>
</div> <!-- end accordion -->
</div> <!-- end collapsible div -->
</td>
<td><a href="example-pager-ajax.html">Example</a></td>
</tr>
<tr id="pager-output">
<td><a href="#" class="permalink">output</a></td>
<td>String</td>
<td>"{startRow} to {endRow} of {totalRows} rows"</td>
<td>This option allows you to format the output display which can show the current page, total pages, filtered pages, current start and end rows, total rows and filtered rows (v2.0.9; <span class="version updated">v2.28.4</span>).
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_output</code><br>
<p></p>
In <span class="version updated">v2.28.4</span>
<p>The <a href="#pager-csspagedisplay">output</a> element can now include two data-attributes, <code>data-pager-output</code> and <code>data-pager-output-filtered</code> which override this setting <em>string</em> when set.</p>
<pre class="prettyprint lang-html"><span class="pagedisplay" data-pager-output="{startRow:input} – {endRow} / {totalRows} total rows" data-pager-output-filtered="{startRow:input} – {endRow} / {filteredRows} of {totalRows} total rows"></span></pre>
<p>It will not override this option if set as a function, or if a specific <a href="#object">output is returned</a> from the server through ajax.</p>
In <span class="version updated">v2.27.7</span>, this option can also be set as a function
<pre class="prettyprint lang-js">output: function(table, pager) {
return 'page ' + pager.startRow + ' - ' + pager.endRow;
}</pre>
This option replaced the original <code>separator</code> option, which only separated the page number from the total number of pages. The formatted output from this option is placed inside the information block targeted by the <code>cssPageDisplay</code> option.<br>
<br>
Use it as follows:
<pre class="prettyprint lang-js">$(function() {
$("table")
.tablesorter()
.tablesorterPager({
output: '{startRow} to {endRow} of {totalRows} rows'
});
});</pre>The following tags are replaced within the output string:
<table class="info">
<thead>
<tr><td>Tag</td><td>Replaced with</td></tr>
</thead>
<tbody>
<tr><td><code>{size}</code></td><td>The current pager size</td></tr>
<tr><td><code>{page}</code></td><td>The current pager page</td></tr>
<tr><td><code>{page:input}</code></td><td>The current pager page within an input (<span class="version">v2.17.6</span>)</td></tr>
<tr><td><code>{totalPages}</code></td><td>Total number of pager pages</td></tr>
<tr><td><code>{filteredPages}</code></td><td>Total number of pages left after being filtered</td></tr>
<tr><td><code>{startRow}</code></td><td>Starting row number currently displayed</td></tr>
<tr><td><code>{startRow:input}</code></td><td>Starting row number currently displayed within an input (<span class="version">v2.17.6</span>)</td></tr>
<tr><td><code>{endRow}</code></td><td>Ending row number currently displayed</td></tr>
<tr><td><code>{filteredRows}</code></td><td>Total number of rows left after being filtered</td></tr>
<tr><td><code>{totalRows}</code></td><td>Total number of rows</td></tr>
</tbody>
</table></div>
</td>
<td>
<a href="example-pager.html">1</a>
<a href="example-pager-ajax.html">2</a>
<a href="example-pager-filtered.html">3</a>
<a href="example-option-theme-bootstrap-v4.html">4</a>
</td>
</tr>
<tr id="pager-updatearrows">
<td><a href="#" class="permalink">updateArrows</a></td>
<td>Boolean</td>
<td>true</td>
<td>
If <code>true</code>, the addon hides the left pager arrow on the first page and right pager arrow on the last page.
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_updateArrows</code><br>
<br>
If <code>true</code> the classname from the <code>cssDisabled</code> option is applied to the arrows when at either page extreme.</div>
</td>
<td><a href="example-pager.html">Example</a></td>
</tr>
<tr id="pager-page">
<td><a href="#" class="permalink">page</a></td>
<td>Numeric</td>
<td>0</td>
<td>
Set the starting page of the pager (zero-based index).
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_startPage</code>
</div>
</td>
<td><a href="example-pager.html">Example</a></td>
</tr>
<tr id="pager-page-reset">
<td><a href="#" class="permalink">pageReset</a></td>
<td>Numeric, Boolean</td>
<td>0</td>
<td>
Reset pager to this page after filtering; set to desired page number (zero-based index), or <code>false</code> to not change page at filter start (<span class="version updated">v2.16</span>).
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_pageReset</code>
</div>
</td>
<td></td>
</tr>
<tr id="pager-size">
<td><a href="#" class="permalink">size</a></td>
<td>Numeric</td>
<td>10</td>
<td>
Set initial number of visible rows. This value is changed by the dropdown selector targeted by the <a href="#pager-csspagesize"><code>cssPageSize</code></a> option.
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_size</code>
<p>Set this option to <code>'all'</code> to show all rows (added <span class="version">v2.26.0</span>).</p>
</div>
</td>
<td><a href="example-pager.html">Example</a></td>
</tr>
<tr id="save-pages">
<td><a href="#" class="permalink">savePages</a></td>
<td>Boolean</td>
<td>true</td>
<td>
Saves the current pager page size and number. This option requires the <a href="#function-storage"><code>$.tablesorter.storage</code></a> script in the <code>jquery.tablesorter.widgets.js</code> file (<span class="version">v2.11</span>).
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_savePages</code>
</div>
</td>
<td><a href="example-pager.html">Example</a></td>
</tr>
<tr id="custom-storage">
<td><a href="#" class="permalink">storageKey</a></td>
<td>String</td>
<td>"tablesorter-pager"</td>
<td>
Saves tablesorter paging to custom key if defined. Key parameter name used by the <a href="#function-storage"><code>$.tablesorter.storage</code></a> function. Useful if you have multiple tables defined (<span class="version">v2.15</span>)
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_storageKey</code>
</div>
</td>
<td><a href="example-pager.html">Example</a></td>
</tr>
<tr id="pager-fixedheight">
<td><a href="#" class="permalink">fixedHeight</a></td>
<td>Boolean</td>
<td>false</td>
<td>Maintain the height of the table even when fewer than the set number of records is shown (v2.1; updated 2.7.1).
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_fixedHeight</code><br>
<br>
This option replaced the original <code>positionFixed</code> and <code>offset</code> options which set the absolute position of the pager block.<br>
<br>
If <code>true</code>, it should maintain the height of the table, even when viewing fewer than the set number of records (go to the last page of any demo to see this in action). It works by adding an empty row to make up the differences in height.
</div>
</td>
<td><a href="example-pager.html">Example</a></td>
</tr>
<tr id="pager-countchildrows">
<td><a href="#" class="permalink">countChildRows</a></td>
<td>Boolean</td>
<td>false</td>
<td>
If <code>true</code>, child rows will be counted towards the pager set size (<span class="version">v2.13</span>).
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_countChildRows</code><br>
<br>
<span class="label label-warning">*CAUTION*</span> When <code>true</code>, child row(s) may not appear to be attached to its parent row, may be split across pages or
may distort the table if rowspan or cellspans are included within the child row.<br>
<br>
If this option is <code>false</code>, child row(s) will always appear on the same page as its parent.
</div>
</td>
<td></td>
</tr>
<tr id="pager-removerows">
<td><a href="#" class="permalink">removeRows</a></td>
<td>Boolean</td>
<td>false</td>
<td>
If <code>true</code>, rows are removed from the table to speed up the sort of large tables (v2.0.21).
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_removeRows</code><br>
<br>
The original tablesorter plugin (v2.0.5) removed rows automatically, without providing an option. It really does speed up sorting of very large tables, but also breaks updating and modifying table content dynamically.<br>
<br>
If this option is <code>false</code>, the addon only hides the non-visible rows; this is useful if you plan to add/remove rows with the pager enabled.
</div>
</td>
<td><a href="example-pager.html">Example</a></td>
</tr>
<tr id="pager-cssfirst">
<td><a href="#" class="permalink">cssFirst</a></td>
<td>String</td>
<td>".first"</td>
<td>
This option contains a jQuery selector string pointing to the go to first page arrow. See <a href="#pager-container"><code>container</code></a> for full HTML.
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_selectors.first</code>
</div>
</td>
<td><a href="example-pager.html">Example</a></td>
</tr>
<tr id="pager-cssprev">
<td><a href="#" class="permalink">cssPrev</a></td>
<td>String</td>
<td>".prev"</td>
<td>
This option contains a jQuery selector string pointing to the go to previous page arrow. See <a href="#pager-container"><code>container</code></a> for full HTML.
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_selectors.prev</code>
</div>
</td>
<td><a href="example-pager.html">Example</a></td>
</tr>
<tr id="pager-cssnext">
<td><a href="#" class="permalink">cssNext</a></td>
<td>String</td>
<td>".next"</td>
<td>
This option contains a jQuery selector string pointing to the go to next page arrow. See <a href="#pager-container"><code>container</code></a> for full HTML.
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_selectors.next</code>
</div>
</td>
<td><a href="example-pager.html">Example</a></td>
</tr>
<tr id="pager-csslast">
<td><a href="#" class="permalink">cssLast</a></td>
<td>String</td>
<td>".last"</td>
<td>
This option contains a jQuery selector string pointing to the go to last page arrow. See <a href="#pager-container"><code>container</code></a> for full HTML.
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_selectors.last</code>
</div>
</td>
<td><a href="example-pager.html">Example</a></td>
</tr>
<tr id="pager-cssgoto">
<td><a href="#" class="permalink">cssGoto</a></td>
<td>String</td>
<td>".gotoPage"</td>
<td>This option contains a jQuery selector string pointing to the page select dropdown. See <a href="#pager-container"><code>container</code></a> for full HTML (v2.4; <span class="version updated">v2.17.3</span>)
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_selectors.gotoPage</code> (changed from <code>goto</code> in <span class="version updated">v2.17.3</span>)<br>
<br>
Please note that this select dropdown is initially empty and automatically updated by the plugin with the correct number of pages, which depends on the <a href="#pager-size"><code>size</code></a> setting.
</div>
</td>
<td><a href="example-pager.html">Example</a></td>
</tr>
<tr id="pager-csspagedisplay">
<td><a href="#" class="permalink">cssPageDisplay</a></td>
<td>String</td>
<td>".pagedisplay"</td>
<td>This option contains a jQuery selector string pointing to the output element (v2.0.9)
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_selectors.pageDisplay</code><br>
<br>
In the original tablesorter (v2.0.5) this option could only target an input, it was updated (v2.0.9) to display the formatted output from the <code>output</code> option inside of any element (span, div or input).
</div>
</td>
<td><a href="example-pager.html">Example</a></td>
</tr>
<tr id="pager-csspagesize">
<td><a href="#" class="permalink">cssPageSize</a></td>
<td>String</td>
<td>".pagesize"</td>
<td>
This option contains a jQuery selector string pointing to the page size selector. See <a href="#pager-container"><code>container</code></a> for full HTML.
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_selectors.pageSize</code>
</div>
</td>
<td><a href="example-pager.html">Example</a></td>
</tr>
<tr id="pager-csserrorrow">
<td><a href="#" class="permalink">cssErrorRow</a></td>
<td>String</td>
<td>"tablesorter-errorRow"</td>
<td>This option contains the class name that is applied to the error information row that is added inside the pager with any ajax exceptions.
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_css.errorRow</code><br>
<br>
Note there is no period "." in front of this class name (it is not a selector).
</div></td>
<td></td>
</tr>
<tr id="pager-cssdisabled">
<td><a href="#" class="permalink">cssDisabled</a></td>
<td>String</td>
<td>"disabled"</td>
<td>This option contains the class name that is applied to disabled pager controls.
<div class="collapsible">
<br>
<span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_css.disabled</code><br>
<br>
More explicitly, this class is applied to the pager arrows when they are at either extreme of pages and the <code>updateArrows</code> option is <code>true</code>. When the pager has been disabled, this class is applied to all controls.<br>
<br>
Note there is no period "." in front of this class name (it is not a selector).
</div></td>
<td></td>
</tr>
</tbody>
<!-- non-sorting tbody -->
<tbody id="pager-removed-options" class="tablesorter-infoOnly">
<tr><th colspan="5">Removed Options</th></tr>
</tbody>
<tbody>
<tr id="widget-filter-anymatch">
<td><a href="#" class="permalink alert">filter_anyMatch</a></td>
<td>Boolean</td>
<td>false</td>
<td>
Filter: This option was <span class="label label-danger">removed</span> in <span class="version updated">v2.15</span>... sorry for the sudden notice.
<div class="collapsible">
<br>
This option has been replaced by the <a href="#widget-filter-external"><code>filter_external</code></a> option.<br>
<br>
Show any rows that match a search query. If this option is <code>true</code> any column match will show that row; but <a href="example-widget-filter-any-match.html#limitations">there are limitations</a> (<span class="version">v2.13.3</span>).<br>
<br>
It is best if this <a href="#widget-filter-anymatch"><code>filter_anyMatch</code></a> option is used with a single search input as follows:
<pre class="prettyprint lang-html"><input class="search" type="search">
<button type="button" class="reset">Reset Search</button></pre>
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_anyMatch : true,
filter_columnFilters: false,
filter_reset: '.reset'
}
});
// Target the $('.search') input using built in functioning
// this binds to the search using "search" and "keyup"
// Allows using filter_liveSearch or delayed search &
// pressing escape to cancel the search
$.tablesorter.filter.bindSearch( $table, $('.search') );
});</pre></div>
</td>
<td></td>
</tr>
<tr id="widget-uitheme">
<td><a href="#" class="permalink alert">uitheme</a></td>
<td>String</td>
<td>"jui"</td>
<td>UiTheme: This option was <span class="label label-danger">removed</span> in v2.19.0!
It has been replaced by <a href="#theme">theme</a>.
<div class="collapsible"><br>
This option contains the name of the theme. Currently jQuery UI ("jui") and Bootstrap ("bootstrap") themes are supported (updated v2.4)
<p>
<span class="label label-warning">* NOTE *</span> only the <code>uitheme</code> widget option was removed. All of the information below is still pertinent and portions have been copied to the core <a href="#theme"><code>theme</code></a> option.
</p>
<p>To modify the class names used, extend from the <a href="#variable-themes"><code>$.tablesorter.themes</code></a> variable as follows:</p>
<pre class="prettyprint lang-js">// Extend the themes to change any of the default class names ** NEW **
$.extend($.tablesorter.themes.jui, {
// change default jQuery uitheme icons - find the full list of icons
// here: http://jqueryui.com/themeroller/ (hover over them for their name)
table : 'ui-widget ui-widget-content ui-corner-all', // table classes
caption : 'ui-widget-content',
// header class names
header : 'ui-widget-header ui-corner-all ui-state-default', // header classes
sortNone : '',
sortAsc : '',
sortDesc : '',
active : 'ui-state-active', // applied when column is sorted
hover : 'ui-state-hover', // hover class
// icon class names
icons : 'ui-icon', // icon class added to the <i> in the header
iconSortNone : 'ui-icon-carat-2-n-s ui-icon-caret-2-n-s', // "caret" class renamed in jQuery v1.12.0
iconSortAsc : 'ui-icon-carat-1-n ui-icon-caret-1-n',
iconSortDesc : 'ui-icon-carat-1-s ui-icon-caret-1-s',
// other
filterRow : '',
footerRow : '',
footerCells : '',
even : 'ui-widget-content', // even row zebra striping
odd : 'ui-state-default' // odd row zebra striping
});</pre>
This widget option replaces the previous <a href="#widgetuitheme">widgetUitheme</a>. All theme css names are now contained within the <code>$.tablesorter.themes</code> variable. Extend the default theme as seen above.<br>
<br>
The class names from the <code>$.tablesorter.themes.{name}</code> variable are applied to the table as indicated.<br>
<br>
As before the jQuery UI theme applies the default class names of <code>"ui-icon-arrowthick-2-n-s"</code> for the unsorted column, <code>"ui-icon-arrowthick-1-s"</code> for the descending sort and <code>"ui-icon-arrowthick-1-n"</code> for the ascending sort. (Modified v2.1; Updated in v2.4). Find more jQuery UI class names by hovering over the Framework icons on this page: <a class="external" href="http://jqueryui.com/themeroller/">http://jqueryui.com/themeroller/</a><br>
<br>
Use the <a href="#widget-uitheme"><code>"uitheme"</code></a> option to change the css class name as follows:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
theme : 'jui', // set theme name from $.tablesorter.themes here
widgets : ["uitheme"], // initialize ui theme styling widget of the table
widgetOptions: {
uitheme : "jui" // this is now optional in v2.7, it is overridden by the theme option
}
});
});</pre>
To add a new theme, define it as follows; replace "custom" with the name of your theme:
<pre class="prettyprint lang-js">$.tablesorter.themes.custom = {
table : 'table', // table classes
header : 'header', // header classes
footerRow : '',
footerCells: '',
icons : 'icon', // icon class added to the <i> in the header
sortNone : 'sort-none', // unsorted header
sortAsc : 'sort-asc', // ascending sorted header
sortDesc : 'sort-desc', // descending sorted header
active : 'sort-active', // applied when column is sorted
hover : 'hover', // hover class
filterRow : 'filters', // class added to the filter row
even : 'even', // even row zebra striping
odd : 'odd' // odd row zebra striping
}</pre></div>
</td>
<td><a href="example-widget-ui-theme.html">Example</a></td>
</tr>
<tr id="pager-offset">
<td><a href="#" class="permalink alert">offset</a></td>
<td>Numeric</td>
<td>0</td>
<td>
Pager: This option was <span class="label label-danger">removed</span>!
<div class="collapsible">
<br>
The original tablesorter pager plugin absolutely positioned the pager controls at the bottom of the table. It appears that this option was intended to tweak the position of the pager container. The option exists, but no code was found.</div>
</td>
<td></td>
</tr>
<tr id="pager-positionfixed">
<td><a href="#" class="permalink alert">positionFixed</a></td>
<td>Boolean</td>
<td>true</td>
<td>
Pager: This option was <span class="label label-danger">removed</span>!
<div class="collapsible">
<br>
If this option were true, the original tablesorter pager plugin would absolutely position the pager controls at the bottom of the table.</div>
</td>
<td></td>
</tr>
<tr id="pager-seperator">
<td><a href="#" class="permalink alert">seperator</a></td>
<td>String</td>
<td>"/"</td>
<td>
Pager: This option was <span class="label label-danger">removed</span>! Use the <a href="#pager-output">output</a> option to allow for more control over the formatting.
<div class="collapsible">
<br>
The original tablesorter pager plugin would combine the current page with the calculated total number of pages within the <a href="#pager-csspagedisplay">cssPageDisplay</a> with this separator string inbetween.</div>
</td>
<td></td>
</tr>
</tbody>
</table>
<a id="methods"></a>
<h1>Methods</h1>
<div class="tip">
<p></p>
tablesorter has some methods available to allow updating, resorting or applying widgets to a table after it has been initialized.
<br>
<span class="label label-info">TIP!</span> Click on the link in the method column to reveal full details (or <a href="#" class="toggleAll">toggle</a>|<a href="#" class="showAll">show</a>|<a href="#" class="hideAll">hide</a> all) or double click to update the browser location.
</div>
<table id="method" class="tablesorter-blue options" data-sortlist="[[0,0]]">
<thead>
<tr>
<th>Method</th>
<th class="sorter-false">Description</th>
<th class="sorter-false">Link</th>
</tr>
</thead>
<tbody>
<tr id="addrows">
<td><a href="#" class="permalink">addRows</a></td>
<td>Use this method to add table rows (v2.0.16; <span class="version updated">v2.23.0</span>).
<div class="collapsible">
<h4>Direct method:</h4>
<p>In <span class="version">v2.23.0</span>, this method can be called directly as follows:</p>
<pre class="prettyprint lang-js">var config = $( 'table' )[ 0 ].config,
$rows = $( 'tr.addedRows' ), // jQuery selector of newly appended row(s)
// applies or reapplies a sort to the table; use false to not update the sort
resort = true, // or [ [0,0], [1,0] ] etc
callback = function( table ) {
// do something
};
$.tablesorter.addRows( config, $rows, resort, callback );</pre>
<h4>Triggered event method:</h4>
It does not work the same as "update" in that it only adds rows, it does not remove them.<br>
<br>
Also, use this method to add table rows while using the pager plugin. If the "update" method is used, only the visible table rows continue to exist.
<pre class="prettyprint lang-js">// Add multiple rows to the table
var row = '<tr><td>Inigo</td><td>Montoya</td><td>34</td>' +
'<td>$19.99</td><td>15%</td><td>Sep 25, 1987 12:00PM</td></tr>',
$row = $( row ),
// resort table using true to reapply the current sort; set to false to prevent resort
// if undefined, the resort value will be obtained from config.resort (added v2.19.0)
// As of v2.19.0, the resort variable can contain a new sortList to be applied
// A callback method was added in 2.3.9.
resort = true, // or [ [0,0], [1,0] ] etc
callback = function( table ) {
alert( 'rows have been added!' );
};
$( 'table' )
.find( 'tbody' ).append( $row )
.trigger( 'addRows', [ $row, resort, callback ] );</pre>
<hr>
<ul>
<li>In <span class="version">v2.23.0</span>,
<ul>
<li>If a table contains only one tbody (not counting information only tbodies; which have a class name from <code>cssInfoBlock</code>), then a row string can be used in this method.
<pre class="prettyprint lang-js">var $table = $( 'table' ),
config = $table[ 0 ].config;
// triggered event method
$table.trigger( 'addRows', [ '<tr>...</tr>', true ] );
// direct method
$.tablesorter.addRows( config, '<tr>...</tr>', true );</pre></li>
<li>So instead of making a jQuery object, appending it to the table, then passing the reference to the method, you can just pass a string. This method doesn't work if a table has multiple tbodies, because the plugin doesn't know where you want to add the rows.</li>
</ul>
</li>
<li>In <span class="version">v2.16.1</span>, the <code>$row</code> parameter can be a row DOM element or jQuery object.</li>
</ul>
</div>
</td>
<td><a href="example-add-rows.html">Example</a></td>
</tr>
<tr id="resettoloadstate">
<td><a href="#" class="permalink">resetToLoadState</a></td>
<td>Use this method reset the table to it's original settings. (<span class="version">v2.17.0</span>).
<div class="collapsible">
Using this method will clear out any settings that have changed since the table was initialized (refreshes the entire table); so any sorting or modified widget options will be cleared.<br>
However, it will not clear any values that were saved to storage. This method is basically like reloading the page.
<pre class="prettyprint lang-js">$('table').trigger('resetToLoadState');</pre>
</div>
</td>
<td></td>
</tr>
<tr id="sort">
<td><a href="#" class="permalink">sort</a></td>
<td>Use this method to initialize a sort while targeting a specific column header (<span class="version">v2.9</span>).
<div class="collapsible">
<pre class="prettyprint lang-js">// Target a specific header
$('table').find('th:eq(2)').trigger('sort');</pre>Using this method will maintain the sorting order; so, if the column is already sorted in ascending order, this method will act as if you manually clicked on the header. Whatever sort order is applied is dependent on other option settings such as <code>initialSortOrder</code>, <code>lockedOrder</code> (set within the <code>headers</code>), <code>sortReset</code> option, <code>sortRestart</code> and will be ignored if the column sort is disabled (<code>sorter: false</code>).
</div>
</td>
<td></td>
</tr>
<tr id="sorton">
<td><a href="#" class="permalink">sorton</a></td>
<td>Use this method to sort an initialized table in the desired order (<span class="version updated">v2.23.0</span>)
<div class="collapsible">
<h4>Direct method:</h4>
<p>In <span class="version">v2.23.0</span>, this method can be called directly as follows:</p>
<pre class="prettyprint lang-js">var config = $( 'table' )[ 0 ].config,
sort = [ [ 0,0 ], [ 1,0 ] ],
callback = function( table ) {
// do something
};
// NOTE: the triggered 'sorton' method requires the sort & callback methods to be
// passed inside an array, this direct method does not.
// Also, notice the "O" of "sortOn" is capitalized in this direct method
$.tablesorter.sortOn( config, sort, callback );</pre>
<h4>Triggered event method:</h4>
<pre class="prettyprint lang-js">// Choose a new sort order
var sort = [ [0,0], [2,0] ],
callback = function( table ) {
alert( 'new sort applied to ' + table.id );
};
// Note that the sort value below is inside of another array (inside another set of square brackets)
// without a callback it could look like this:
$( 'table' ).trigger( 'sorton', [ [[0,0],[2,0]] ] );
// when including a callback method the outer square bracket wrap both parameters (added in 2.3.9).
$( 'table' ).trigger( 'sorton', [ sort, callback ] );</pre>
<span class="label label-warning">*NOTE*</span> using this method to sort ignores the additions from the <a href="#sortforce"><code>sortForce</code></a> and <a href="#sortappend"><code>sortAppend</code></a> options.<br>
<br>
In <span class="version updated">v2.17.0</span>, the sort direction can be set using "a" (ascending), "d" (descending), "n" (next), "s" (same) & "o" (opposite).
<pre class="prettyprint lang-js">$('table').trigger('sorton', [ [[0,"a"],[2,"n"]] ]);</pre>
Please try out the demo (example link) to better understand how these values work.
</div>
</td>
<td><a href="example-trigger-sort.html">Example</a></td>
</tr>
<tr id="sortreset-method">
<td><a href="#" class="permalink">sortReset</a></td>
<td>Use this method to set the table into an unsorted state (v2.4.7; <span class="version updated">v2.23.0</span>).
<div class="collapsible">
<h4>Direct method:</h4>
<p>In <span class="version">v2.23.0</span>, this method can be called directly as follows:</p>
<pre class="prettyprint lang-js">var config = $( 'table' )[ 0 ].config,
callback = function( table ) {
// do something
};
$.tablesorter.sortReset( config, callback );</pre>
<h4>Triggered event method:</h4>
This method immediately resets the entire table sort, while the option only resets the column sort after a third click.<br>
<br>
In <span class="version updated">v2.16.0</span>, a callback function was added to this method.<br>
<br>
<pre class="prettyprint lang-js">// Reset the table (make it unsorted)
var callback = function( table ) {
console.log( 'sort has been reset' );
};
$( 'table' ).trigger( 'sortReset', [ callback ] );</pre>
<span class="label label-warning">*NOTE*</span> Don't confuse this method with the <a href="#sortreset"><code>sortReset</code> option</a>.
</div>
</td>
<td><a href="example-method-sortreset.html">Example</a></td>
</tr>
<tr id="update">
<td><a href="#" class="permalink">update</a> / <a href="#" class="permalink">updateRows</a></td>
<td>Update the <code>tbody</code>'s stored data (<code>update</code> & <code>updateRows</code> do exactly the same thing; <span class="version updated">v2.23.0</span>)
<div class="collapsible">
<h4>Direct method:</h4>
<p>In <span class="version">v2.23.0</span>, this method can be called directly as follows:</p>
<pre class="prettyprint lang-js">var config = $( 'table' )[ 0 ].config,
// applies or reapplies a sort to the table; use false to not update the sort
resort = true, // or [ [0,0], [1,0] ] etc
callback = function( table ) {
// do something
};
$.tablesorter.update( config, resort, callback );</pre>
<h4>Triggered event method:</h4>
<pre class="prettyprint lang-js">// Add new content
$( 'table tbody' ).append( html );
// let the plugin know that we made a update
// the resort flag set to true will trigger an automatic resort using the current sort
// if set to false, no new sort will be applied; or set it to any sortList value (e.g. [[0,0]]; new v2.19.0)
// A callback method was added in 2.3.9.
var resort = true,
callback = function( table ) {
alert( 'new sort applied' );
};
$( 'table' ).trigger( 'update', [ resort, callback ] );
// As of version 2.19.0, if the resort parameter is undefined, the setting from the config.resort will be used
// As of version 2.0.14, the table will automatically resort after the update (if the "resort" flag is true
// & will use the current sort selection), so include the following if you want to specify a different sort
// set sorting column and direction, this will sort on the first and third column
var sorting = [ [2,1], [0,0] ];
// method to use prior to v2.19.0
// $( 'table' )
// .trigger( 'update', [ false ] )
// .trigger( 'sorton', [ sorting ] );
// After v2.19.0; do the following to apply a new sort after updating
// if sorting is an empty array [], then the sort will be reset
$( 'table' ).trigger( 'update', [ sorting ] );</pre>
<span class="label label-info">NOTE</span> <code>updateRows</code> was added to work around the issue of using jQuery with the Prototype library. Triggering an "update" would make Prototype clear the tbody; Please see <a href="https://github.com/Mottie/tablesorter/issues/217">issue #217</a> for more details.
</div>
</td>
<td><a href="example-ajax.html">Example</a></td>
</tr>
<tr id="updateall">
<td><a href="#" class="permalink">updateAll</a></td>
<td>Update a column of cells (<code>thead</code> and <code>tbody</code>) (<span class="version">v2.8</span>; <span class="version updated">v2.23.0</span>).
<div class="collapsible">
<h4>Direct method:</h4>
<p>In <span class="version">v2.23.0</span>, this method can be called directly as follows:</p>
<pre class="prettyprint lang-js">var config = $( 'table' )[ 0 ].config,
// applies or reapplies a sort to the table; use false to not update the sort
resort = true, // or [ [0,0], [1,0] ] etc
callback = function( table ) {
// do something
};
$.tablesorter.updateAll( config, resort, callback );</pre>
<h4>Triggered event method:</h4>
<pre class="prettyprint lang-js">// Change thead & tbody column of cells
// remember, "eq()" is zero based & "nth-child()" is 1 based
$("table thead th:eq(2)").html("Number");
// add some random numbers to the table cell
$("table tbody").find('td:nth-child(3)').html(function(i,h) {
return Math.floor(Math.random()*10) + 1; // random number from 0 to 10
});
// reapply the current sort if resort = true
// do not reapply the current sort if resort = false
// if undefined, resort will be obtained from config.resort (added v2.19.0)
// as of v2.19.0, apply a new sort if resort = [[0,0]] (or whatever)
// or the sort is reset if resort = []
var resort = true,
// add a callback, as desired
callback = function(table) {
alert('table updated!');
};
// let the plugin know that we made a update, then the plugin will
// automatically sort the table based on the header settings
$("table").trigger("updateAll", [ resort, callback ]);</pre></div>
</td>
<td><a href="example-update-all.html">Example</a></td>
</tr>
<tr id="updatecache">
<td><a href="#" class="permalink">updateCache</a></td>
<td>Update the parsers, only if not defined, then update the internal cache (<span class="version">v2.15.4</span>; <span class="version updated">v2.27.0</span>).
<div class="collapsible">
<h4>Direct method:</h4>
<p>In <span class="version">v2.23.0</span>, this method can be called directly as follows:</p>
<pre class="prettyprint lang-js">var config = $( 'table' )[ 0 ].config,
// optional parameter to target tbodies
$tbodies = $( 'table' ).children( 'tbody.totals' ),
callback = function( table ) {
// do something
};
$.tablesorter.updateCache( config, callback, $tbodies );</pre>
<h4>Triggered event method:</h4>
<p><span class="label label-warning">*NOTE*</span> In <span class="version updated">v2.22.2</span>, a new parameter was added to allow passing a jQuery object containing tbodies to be added to the table (for the tbody sorting widget).</p>
<p>This method is used by the pager (addon & widget) to update the data stored within the cache after the content has been updated using ajax.</p>
<pre class="prettyprint lang-js">// optional callback function
var callback = function( table ) { /* do something */ },
// optional in v2.22.2; defaults to table.config.$tbodies if undefined
$tbodies = $( 'table' ).children( 'tbody' );
$("table").trigger("updateCache", [ callback, $tbodies ] );</pre></div>
</td>
<td><a href="example-update-all.html">Example</a></td>
</tr>
<tr id="appendcache">
<td><a href="#" class="permalink">appendCache</a></td>
<td>Adds all of the cached table rows back into the table (<span class="version updated">v2.23.0</span>).<br>
<div class="collapsible"><br>
This method was originally designed to be used with the pager. It should be used under these conditions:
<ul>
<li>When the pager <code>removeRows</code> option is <code>true</code>.</li>
<li>When not using the "updateCell" or "addRows" methods.</li>
<li>Before manually adding or removing table rows.</li>
<li>And, before triggering an "update".</li>
</ul>
Note: The entire table is stored in the cache, but when using the pager with the <a href="#pager-removerows"><code>removeRows</code> option</a> set to <code>true</code>, only the visible portion is actually exists within the table. So, use this option to add all stored rows back into the table before manually changing the contents. Otherwise, if any update method is triggered, only the visible rows will be added back to the cache.
<h4>Direct method:</h4>
<p>In <span class="version">v2.23.0</span>, this method can be called directly as follows:</p>
<pre class="prettyprint lang-js">var config = $( 'table' )[ 0 ].config;
// there is no callback available when using this direct method because
// it may divert to pager injected functions, if the pager is being used
$.tablesorter.appendCache( config );</pre>
<h4>Triggered event method:</h4>
<pre class="prettyprint lang-js">// how to update the table contents
$("table")
.trigger("appendCache")
.append('<tr>...</tr>') // add new row(s), or delete rows
.trigger("update"); // update the cache</pre>
</div>
</td>
<td></td>
</tr>
<tr id="updateheaders">
<td><a href="#" class="permalink">updateHeaders</a></td>
<td>Refresh table headers only (<span class="version">v2.23.0</span>).
<div class="collapsible">
<h4>Direct method:</h4>
<p>In <span class="version">v2.23.0</span>, this method can be called directly as follows:</p>
<pre class="prettyprint lang-js">var config = $( 'table' )[ 0 ].config,
callback = function( table ) {
// do something
};
$.tablesorter.updateHeaders( config, callback );</pre>
<h4>Triggered event method:</h4>
<pre class="prettyprint lang-js">$(function() {
$( 'table' ).tablesorter();
// click on a button somewhere on the page to update header index
$( 'button' ).click( function() {
// Do something after the cell update in this callback function
var $headerCell = $('thead th:eq(1)'),
index = $headerCell.data( 'counter' ) || 0,
callback = function( table ) {
/* do something */
};
// change header text
$headerCell
.html( 'header click #' + index )
// update header data
.data( 'counter', index++ );
// update the header, includes rebinding events & using the header template
$( 'table' ).trigger( 'updateHeaders', callback );
return false;
});
});</pre></div>
</td>
<td></td>
</tr>
<tr id="updatecell">
<td><a href="#" class="permalink">updateCell</a></td>
<td>Update a table cell in the tablesorter data (<span class="version updated">v2.23.0</span>).
<div class="collapsible">
<h4>Direct method:</h4>
<p>In <span class="version">v2.23.0</span>, this method can be called directly as follows:</p>
<pre class="prettyprint lang-js">var config = $( 'table' )[ 0 ].config,
$cell = $( 'td.random' ), // jQuery selector or DOM element of newly updated cell
// applies or reapplies a sort to the table; use false to not update the sort
resort = true, // or [ [0,0], [1,0] ] etc
callback = function( table ) {
// do something
};
$.tablesorter.updateCell( config, $cell, resort, callback );</pre>
<h4>Triggered event method:</h4>
<pre class="prettyprint lang-js">$(function() {
$( 'table' ).tablesorter();
$( 'td.discount' ).click( function() {
// Do we want to reapply the current sort on the column?
// see updateRow for other resort settings as of v2.19.0
// if resort is undefined, the value from config.resort (added v2.19.0) will be used
var resort = false,
// Do something after the cell update in this callback function
callback = function( table ) {
/* do something */
},
// randomize a number & add it to the cell
discount = '$' + Math.round( Math.random() * Math.random() * 100 ) + '.' +
( '0' + Math.round( Math.random() * Math.random() * 100 ) ).slice( -2 );
// add new table cell text
$( this ).text( discount );
// update the table, so the tablesorter plugin can update its value
// set resort flag to false to prevent automatic resort (since we're using a different sort below)
// prior to v2.19.0, leave the resort flag as undefined, or with any other value, to automatically resort the table
// new resort values can be set as of v2.19.0 - please see the "updateRow" documentation for more details
// $( 'table' ).trigger( 'updateCell', [ this ] ); < - resort is undefined so the table WILL resort
$( 'table' ).trigger( 'updateCell', [ this, resort, callback ] );
// As of version 2.0.14, the table will automatically resort (using the current sort selection)
// after the update, so include the following if you want to specify a different sort
// prior to v2.19.0, set sorting column and direction, this will sort on the first and third column
// after v2.19.0, add any new sort to the "resort" variable above
var sorting = [ [ 3,1 ] ];
$( 'table' ).trigger( 'sorton', [ sorting ] );
return false;
});
});</pre></div>
</td>
<td><a href="example-update-cell.html">Example</a></td>
</tr>
<tr id="applywidgetid">
<td><a href="#" class="permalink">applyWidgetId</a></td>
<td>Apply the selected widget to the table, but the widget will not continue to be applied after each sort. See the example, it's easier than describing it (<span class="version updated">v2.25.4</span>).
<div class="collapsible">
<p>In <span class="version updated">v2.25.4</span>, the direct method will now correctly accept <code>$('table')</code>. Previously, only <code>$('table')[0]</code> would work.</p>
<p>In <span class="version updated">v2.25.0</span>, this method ensures that the widget initialization code is executed as well as the format function. So now a widget that was not previously initialized or had been previously removed, can be reapplied.</p>
<p>Only <em>one</em> widget can be applied at a time using this method.</p>
<h4>Direct method:</h4>
<pre class="prettyprint lang-js">$.tablesorter.applyWidgetId( $('table'), 'zebra' );</pre>
<h4>Triggered event method:</h4>
<pre class="prettyprint lang-js">$(function() {
// initialize tablesorter without the widget
$('table').tablesorter();
// click a button to apply the zebra striping
$('button').click(function() {
$('table').trigger('applyWidgetId', 'zebra');
return false;
});
});</pre></div>
</td>
<td><a href="example-apply-widget.html">Example</a></td>
</tr>
<tr id="applywidgets">
<td><a href="#" class="permalink">applyWidgets</a></td>
<td>Apply the set widgets to the table (<span class="version updated">v2.29.0</span>).
<div class="collapsible">
<p>In <span class="version updated">v2.29.0</span>, access to the callback method was added.</p>
<p>This method only updates the widgets listed in the <a href="#widgets"><code>table.config.widgets</code></a> option.</p>
<pre class="prettyprint lang-js">// This method applies the widgets already added to tablesorter
$('table').trigger('applyWidgets', callback);
</pre>
Use this method can be used to add multiple widgets to the table.
<pre class="prettyprint lang-js">var $table = $( 'table' );
$table[0].config.widgets = [ 'zebra', 'columns' ];
$table.trigger('applyWidgets', function() {
console.log('new widgets applied');
});
</pre></div>
</td>
<td><a href="example-apply-widget.html">Example</a></td>
</tr>
<tr id="removewidget">
<td><a href="#" class="permalink">removeWidget</a></td>
<td>Remove the named widget from the table (<span class="version">v2.25.0</span>).
<div class="collapsible">
<p>This method will remove the named widget(s) from the table.</p>
<h4>Direct method:</h4>
<pre class="prettyprint lang-js">$.tablesorter.removeWidget( $( 'table' ), widget );</pre>
<h4>Triggered event method:</h4>
<pre class="prettyprint lang-js">$( 'table' ).trigger( 'removeWidget', widget );</pre>
<p>The <code>widget</code> parameter can be used as follows:</p>
<ul>
<li>Single widget name - string
<pre class="prettyprint lang-js">// only remove zebra widget
$( 'table' ).trigger( 'removeWidget', 'zebra' );</pre>
</li>
<li>Multiple widgets names - array or string (space or comma separated)
<pre class="prettyprint lang-js">// remove multiple widgets (the below methods are all equivalent)
$( 'table' ).trigger( 'removeWidget', 'zebra columns' );
$( 'table' ).trigger( 'removeWidget', 'zebra, columns' );
$( 'table' ).trigger( 'removeWidget', [ 'zebra', 'columns' ] );</pre>
</li>
<li><code>true</code> - boolean (removes all widgets; passing <code>false</code> does nothing)
<pre class="prettyprint lang-js">// remove all widgets
$( 'table' ).trigger( 'removeWidget', true );</pre>
</li>
</ul>
</div>
</td>
<td><a href="example-apply-widget.html">Example</a></td>
</tr>
<tr id="destroy">
<td><a href="#" class="permalink">destroy</a></td>
<td>Use this method to remove tablesorter from the table (v2.3.2; <span class="version updated">v2.16</span>).
<div class="collapsible">
<pre class="prettyprint lang-js">// Remove tablesorter and all classes
$("table").trigger("destroy");
// Remove tablesorter and all classes but the "tablesorter" class on the table
// callback is a function
$("table").trigger("destroy", [false, callback]);</pre></div>
</td>
<td></td>
</tr>
<tr id="refreshwidgets">
<td><a href="#" class="permalink">refreshWidgets</a></td>
<td>Refresh the currently applied widgets. Depending on the options, it will completely remove all widgets, then re-initialize the current widgets or just remove all non-current widgets (v2.4; <span class="verison updated">v2.19.0</span>).
<div class="collapsible"><br>
Trigger this method using either of the following methods (they are equivalent):
<pre class="prettyprint lang-js">// trigger a refresh widget event
$('table').trigger('refreshWidgets', [doAll, dontapply]);
// Use the API directly
$.tablesorter.refreshWidgets(table, doAll, dontapply)</pre>
<ul>
<li>If <code>doAll</code> is <code>true</code> it removes all widgets from the table. If <code>false</code> only non-current widgets (from the <code>widgets</code> option) are removed.</li>
<li>When done removing widgets, the widget re-initializes the currently selected widgets, unless the <code>dontapply</code> parameter is <code>true</code> leaving the table widget-less.</li>
<li>Note that if the <code>widgets</code> option has any named widgets, they will be re-applied to the table when it gets resorted. So if you want to completely remove all widgets from the table, also clear out the widgets option <code>$('table')[0].config.widgets = [];</code></li>
</ul>
</div>
</td>
<td><a href="example-apply-widget.html">Example</a></td>
</tr>
</tbody>
<!-- non-sorting tbody -->
<tbody id="methods-widgets" class="tablesorter-infoOnly">
<tr><th colspan="3">Widget Methods</th></tr>
</tbody>
<tbody>
<tr id="search">
<td><a href="#" class="permalink">search</a></td>
<td>filter: Trigger the filter widget to update the search from current inputs and/or selections (v2.4; <span class="version updated">v2.15</span>).
<div class="collapsible">
This first method sends an array with the search strings to the filter widget.<pre class="prettyprint lang-js">$(function() {
// apply "2?%" filter to the fifth column (zero-based index)
var columns = [];
columns[4] = '2?%'; // or define the array this way [ '', '', '', '', '2?%' ]
$('table').trigger('search', [columns]);
});</pre>
or, directly add the search string to the filter input as follows:<pre class="prettyprint lang-js">$(function() {
// apply "2?%" filter to the fifth column (zero-based index)
$('table').find('input.tablesorter-filter').eq(4).val('2?%');
$('table').trigger('search', false); // add a false flag to skip the search delay
});</pre>
In <span class="version updated">v2.15</span>, one additional parameter can be added to the array to perform an "any-match" of the table; <span class="label label-warning">Warning!</span> please note that if no external input (with a <code>data-column="all"</code> is attached using <a href="#function-bindsearch"><code>bindSearch</code></a> function) is visible, the user will not know that a filter has been applied. <pre class="prettyprint lang-js">// in a table with 4 columns; set the 5th parameter to any-match
$('table').trigger( 'search', [['', '', '', '', 'orange']] ); // find orange in any column</pre>
</div>
</td>
<td></td>
</tr>
<tr id="filterreset">
<td><a href="#" class="permalink">filterReset</a></td>
<td>filter: Trigger the filter widget to reset the search criteria (v2.7.7).
<div class="collapsible"><br>
If you are using the <code>filter_formatter</code> option to add custom input elements, this function may not work on those columns. Please refer to the <code>filter_formatter</code> section for more details.
<pre class="prettyprint lang-js">$(function() {
// this is the same code that the "filter_reset" element runs to clear out the filters.
$('button').click(function() {
$('table').trigger('filterReset');
return false;
});</pre>
This method is used by the <a href="#widget-filter-reset"><code>filter_reset</code> option</a> when defined.
</div>
</td>
<td><a href="example-widget-filter.html">Example</a></td>
</tr>
<tr id="filterandsortreset">
<td><a href="#" class="permalink">filterAndSortReset</a></td>
<td>filter: Trigger the filter widget to reset the sort & reset the search criteria (<span class="version">v2.28.7</span>).
<div class="collapsible">
<p>
This combination reset was added to prevent issues with the widgets not being updated after a combination of <a href="#filterreset"><code>filterReset</code></a> and <a href="#sortreset"><code>sortReset</code></a> due to internal timers preventing multiple widget applications in a row.
</p>
This method does not include a callback parameter similiar to the <code>sortReset</code> method.
<pre class="prettyprint lang-js">$(function() {
$('button').click(function() {
$('table').trigger('filterAndSortReset');
return false;
});</pre>
</div>
</td>
<td></td>
</tr>
<tr id="filterresetsaved">
<td><a href="#" class="permalink">filterResetSaved</a></td>
<td>filter: Make the filter widget reset any saved searches (<span class="version">v2.25.6</span>).
<div class="collapsible"><br>
Use this as follows:
<pre class="prettyprint lang-js">$(function() {
// this is the same code that the "filter_reset" element runs to clear out the filters.
$('button').click(function() {
$('#myTable').trigger('filterResetSaved');
return false;
});</pre>
This is the equivalent of executing this function:
<pre class="prettyprint lang-js">// clear the current table stored filters
$.tablesorter.storage( $('#myTable'), 'tablesorter-filters', '' );</pre>
</div>
</td>
<td><a href="example-widget-filter.html">Example</a></td>
</tr>
<tr id="savesortreset">
<td><a href="#" class="permalink">saveSortReset</a></td>
<td>Trigger the saveSort widget to clear any saved sorts for that specific table (v2.7.11).
<div class="collapsible">
<pre class="prettyprint lang-js">$(function() {
$('button').click(function() {
$('table').trigger('saveSortReset');
return false;
});
});</pre></div>
</td>
<td></td>
</tr>
</tbody>
<!-- non-sorting tbody -->
<tbody id="methods-pager" class="tablesorter-infoOnly">
<tr><th colspan="3">Pager Methods</th></tr>
</tbody>
<tbody>
<tr id="pagesize">
<td><a href="#" class="permalink">pageSize</a></td>
<td>Trigger the pager to change the page size (v2.7.4; <span class="version updated">v2.24.0</span>).
<div class="collapsible">
<pre class="prettyprint lang-js">$(function() {
$('table').trigger('pageSize', 15);
});</pre>
In <span class="version updated">v2.24.0</span>, this option will now accept "all" as a setting, and in turn display all rows.
</div>
</td>
<td></td>
</tr>
<tr id="pageset">
<td><a href="#" class="permalink">pageSet</a></td>
<td>Trigger the pager to change the current page (v2.7.7).
<div class="collapsible">
<br>
If no value is passed, the pager will reset to page 1; otherwise, pass a "one-based" index of the desired page
<pre class="prettyprint lang-js">$(function() {
$('table').trigger('pageSet', 3); // pass a one-based index
});</pre></div>
</td>
<td></td>
</tr>
<tr id="pageandsize">
<td><a href="#" class="permalink">pageAndSize</a></td>
<td>Trigger the pager to change the current page & size (<span class="version">v2.19.0</span>; ; <span class="version updated">v2.24.0</span>).
<div class="collapsible">
<br>
If no value is passed, the pager will reset to page 1 with the original pager size setting; otherwise, pass a "one-based" index of the desired page and the pager size as an array
<pre class="prettyprint lang-js">$(function() {
$('table').trigger('pageAndSize', [ 2, 20 ]); // pass a one-based page index & page size
});</pre>
In <span class="version updated">v2.24.0</span>, this option will now accept "all" as a page size setting, and in turn display all rows; the page number will be force to page one.
</div>
</td>
<td></td>
</tr>
<tr id="pagerupdate">
<td><a href="#" class="permalink">pagerUpdate</a></td>
<td>Force the pager to update the table with the current settings (<span class="version">v2.19.0</span>).
<div class="collapsible">
<br>
If there is a need, this method will force the (ajax and non-ajax) pager to update. Use it as follows:
<pre class="prettyprint lang-js">$(function() {
$('table').trigger('pagerUpdate');
});</pre>
Or, if you need, you can optionally pass a new page number:
<pre class="prettyprint lang-js">$(function() {
$('table').trigger('pagerUpdate', 3); // update and set to page 3
});</pre>
</div>
</td>
<td></td>
</tr>
<tr id="destroypager">
<td><a href="#" class="permalink">destroyPager</a></td>
<td>Calling this method will reveal the entire table, remove the pager functionality, and hide the actual pager (v2.0.16; <span class="version updated">v2.23.0</span>).
<div class="collapsible">
<p>In <span class="version updated">v2.23.0</span>, this method was changed from <code>destroy.pager</code> to <code>destroyPager</code> because of issues with unique namespacing.</p>
<pre class="prettyprint lang-js">$(function() {
$('table').trigger('destroyPager');
});</pre>
The only way to restore the pager addon is to re-initialize the pager addon:
<br>
<pre class="prettyprint lang-js">$(function() {
$('table').tablesorterPager(pagerOptions);
});</pre></div>
</td>
<td><a href="example-pager.html">Example</a></td>
</tr>
<tr id="disablepager">
<td><a href="#" class="permalink">disablePager</a></td>
<td>This method will put the pager into a disabled state (v2.0.21.2; <span class="version updated">v2.23.0</span>).
<div class="collapsible">
<p>In <span class="version updated">v2.23.0</span>, this method was changed from <code>disable.pager</code> to <code>disablePager</code> because of issues with unique namespacing.</p>
The disabled state will reveal all table rows and disable, but not hide, pager controls.
<br>
<pre class="prettyprint lang-js">$(function() {
$('table').trigger('disablePager');
});</pre></div>
</td>
<td><a href="example-pager.html">Example</a></td>
</tr>
<tr id="enablepager">
<td><a href="#" class="permalink">enablePager</a></td>
<td>This method will re-enable the pager, but only from the disabled state (v2.0.21.2; <span class="version updated">v2.23.0</span>).
<div class="collapsible">
<p>In <span class="version updated">v2.23.0</span>, this method was changed from <code>enable.pager</code> to <code>enablePager</code> because of issues with unique namespacing.</p>
<pre class="prettyprint lang-js">$(function() {
$('table').trigger('enablePager');
});</pre></div>
</td>
<td><a href="example-pager.html">Example</a></td>
</tr>
</tbody>
</table>
<a id="events"></a>
<h1>Events</h1>
<div class="tip">
<p></p>
tablesorter has some methods available to allow updating, resorting or applying widgets to a table after it has been initialized.
<br>
<span class="label label-info">TIP!</span> Click on the link in the event column to reveal full details (or <a href="#" class="toggleAll">toggle</a>|<a href="#" class="showAll">show</a>|<a href="#" class="hideAll">hide</a> all) or double click to update the browser location.
</div>
<table id="event" class="tablesorter-blue options" data-sortlist="[[0,0]]">
<thead>
<tr>
<th>Event</th>
<th class="sorter-false">Description</th>
<th class="sorter-false">Link</th>
</tr>
</thead>
<tbody>
<tr id="tablesorter-initialized">
<td><a href="#" class="permalink">tablesorter-initialized</a></td>
<td>This event fires when tablesorter has completed initialization. (v2.2).
<div class="collapsible">
<pre class="prettyprint lang-js">$(function() {
// bind to initialized event BEFORE initializing tablesorter*
$("table")
.bind("tablesorter-initialized",function(e, table) {
// do something after tablesorter has initialized
});
// initialize the tablesorter plugin
$("table").tablesorter({
// this is equivalent to the above bind method
initialized : function(table) {
// do something after tablesorter has initialized
}
});
});</pre><small>* Note: bind to all initialization events before initializing tablesorter; because most of the time, if bound after, the events will fire before the binding occurs</small>.</div>
</td>
<td></td>
</tr>
<tr id="sortbegin">
<td><a href="#" class="permalink">sortBegin</a></td>
<td>This event fires immediately before tablesorter begins resorting the table.
<div class="collapsible">
<pre class="prettyprint lang-js">$(function() {
// initialize the tablesorter plugin
$("table").tablesorter();
// bind to sort events
$("table").bind("sortBegin",function(e, table) {
// do something crazy!
});
});</pre></div>
</td>
<td></td>
</tr>
<tr id="sortstart">
<td><a href="#" class="permalink">sortStart</a></td>
<td>This event fires immediately after the tablesorter header has been clicked, initializing a resort.
<div class="collapsible">
<pre class="prettyprint lang-js">$(function() {
// initialize the tablesorter plugin
$("table").tablesorter();
// bind to sort events
$("table")
.bind("sortStart",function(e, table) {
$("#overlay").show();
})
.bind("sortEnd",function(e, table) {
$("#overlay").hide();
});
});</pre></div>
</td>
<td><a href="example-triggers.html">Example</a></td>
</tr>
<tr id="sortend">
<td><a href="#" class="permalink">sortEnd</a></td>
<td>This event fires when tablesorter has completed resorting the table.
<div class="collapsible">
<pre class="prettyprint lang-js">$(function() {
// initialize the tablesorter plugin
$("table").tablesorter();
// bind to sort events
$("table")
.bind("sortStart",function(e, table) {
$("#overlay").show();
})
.bind("sortEnd",function(e, table) {
$("#overlay").hide();
});
});</pre></div>
</td>
<td><a href="example-triggers.html">Example</a></td>
</tr>
<tr id="updatecomplete">
<td><a href="#" class="permalink">updateComplete</a></td>
<td>This event fires after tablesorter has completed updating (v2.3.9).
<div class="collapsible">
This occurs after an "update", "updateAll", "updateCell" or "addRows" method was called, but before any callback functions are executed.
<pre class="prettyprint lang-js">$(function() {
// initialize the tablesorter plugin
$('table')
.tablesorter()
// bind to sort events
.bind('updateComplete', function(e, table) {
// do something after the table has been altered;
});
});</pre></div>
</td>
<td></td>
</tr>
<tr id="tablesorterready">
<td><a href="#" class="permalink">tablesorter-ready</a></td>
<td>This event fires after tablesorter has complete applying all widgets and is ready for its next action (<span class="version">v2.24.0</span>).
<div class="collapsible">
This event occurs after an "updateComplete" and "pagerComplete" event. There may be some other table interaction if a widget includes any <code>setTimeout</code> functions.
<pre class="prettyprint lang-js">$(function() {
// initialize the tablesorter plugin
$('table')
.tablesorter()
// bind to sort events
.bind('tablesorter-ready', function(e, table) {
// do something after tablesorter has finished interacting with the table;
});
});</pre></div>
</td>
<td></td>
</tr>
<tr id="refreshcomplete">
<td><a href="#" class="permalink">refreshComplete</a></td>
<td>This event fires after tablesorter has completed executing the <a href="#refreshwidgets">refreshWidget</a> method (<span class="version">v2.19.0</span>)
<div class="collapsible">
<br>
Use it as follows:
<pre class="prettyprint lang-js">$(function() {
// initialize the tablesorter plugin
$('table')
.tablesorter()
// bind to sort events
.bind('refreshComplete', function(e, table) {
// do something after the 'refreshWidgets' has refreshed
});
});</pre></div>
</td>
<td></td>
</tr>
</tbody>
<!-- non-sorting tbody -->
<tbody id="events-widgets" class="tablesorter-infoOnly">
<tr><th colspan="3">Widget Events</th></tr>
</tbody>
<!-- widget events -->
<tbody>
<tr id="filterinit">
<td><a href="#" class="permalink">filterInit</a></td>
<td>Event triggered when the filter widget has finished initializing (v2.4).
<div class="collapsible"><br>
You can use this event to modify the filter elements (row, inputs and/or selects) as desired. Use it as follows:<pre class="prettyprint lang-js">$(function() {
$('table')
// bind to filter initialized event BEFORE initializing tablesorter*
.bind('filterInit', function(event, config) {
$(this).find('tr.tablesorter-filter-row').addClass('fred');
})
// initialize the sorter
.tablesorter({
widgets : ['filter']
});
});</pre><small>* Note: bind to all initialization events before initializing tablesorter; because most of the time, if bound after, the events will fire before the binding occurs</small>.</div>
</td>
<td><a href="example-option-show-processing.html">Example</a></td>
</tr>
<tr id="filterstart">
<td><a href="#" class="permalink">filterStart</a></td>
<td>Event triggered when the filter widget has started processing the search (v2.4).
<div class="collapsible"><br>
You can use this event to do something like add a class to the filter row. Use it as follows:<pre class="prettyprint lang-js">$(function() {
$('table').bind('filterStart', function(event, filters) {
// filters contains an array of the current filters
$(this).find('tr.tablesorter-filter-row').addClass('filtering');
});
});</pre></div>
</td>
<td><a href="example-option-show-processing.html">Example</a></td>
</tr>
<tr id="filterend">
<td><a href="#" class="permalink">filterEnd</a></td>
<td>Event triggered when the filter widget has finished processing the search (v2.4).
<div class="collapsible"><br>
You can use this event to do something like remove the class added to the filter row when the filtering started. Use it as follows:<pre class="prettyprint lang-js">$(function() {
$('table').bind('filterEnd', function(event, config) {
$(this).find('tr.tablesorter-filter-row').removeClass('filtering');
});
});</pre></div>
</td>
<td><a href="example-option-show-processing.html">Example</a></td>
</tr>
<tr id="stickyheadersinit">
<td><a href="#" class="permalink">stickyHeadersInit</a></td>
<td>Event triggered when the stickyHeader widget has finished initializing (<span class="version">v2.10.4</span>).
<div class="collapsible"><br>
You can use this event to do something like modify content within the sticky header:<pre class="prettyprint lang-js">$(function() {
$('table')
// bind to the init event BEFORE initializing tablesorter*
.bind('stickyHeadersInit', function() {
// this.config.widgetOptions.$sticky contains the entire sticky header table
this.config.widgetOptions.$sticky.find('tr.tablesorter-headerRow').addClass('sticky-styling');
})
// initialize the tablesorter plugin
.tablesorter({
widgets : ['stickyHeaders']
});
});</pre><small>* Note: bind to all initialization events before initializing tablesorter; because most of the time, if bound after, the events will fire before the binding occurs</small>.</div>
</td>
<td></td>
</tr>
<tr id="widgetremoveend">
<td><a href="#" class="permalink">widgetRemoveEnd</a></td>
<td>Event triggered after <em>any</em> widget has finished being removed (<span class="version">v2.29.0</span>).
<div class="collapsible"><br>
You can use this event to do something like remove the class added to the filter row when the filtering started. Use it as follows:<pre class="prettyprint lang-js">$(function() {
$('table').bind('widgetRemoveEnd', function(event, table) {
// do something after widget was removed
});
});</pre>
This method does not include data on which widget was removed.
</div>
</td>
<td><a href="example-option-show-processing.html">Example</a></td>
</tr>
</tbody>
<!-- non-sorting tbody -->
<tbody id="events-pager" class="tablesorter-infoOnly">
<tr><th colspan="3">Pager Events</th></tr>
</tbody>
<!-- Pager addon events -->
<tbody>
<tr id="pagerchange">
<td><a href="#" class="permalink">pagerChange</a></td>
<td>This event fires when the pager plugin begins to render the table on the currently selected page. (v2.0.7).
<div class="collapsible">
<pre class="prettyprint lang-js">$(function() {
// initialize the sorter
$("table")
.tablesorter()
// initialize the pager plugin
.tablesorterPager({
container: $("#pager")
})
// bind to pager events
.bind('pagerChange pagerComplete', function(event, options) {
// options = table.config.pager (pager addon)
// options = table.config (pager widget) - so use options.pager.page below
// this.totalPages contains the total number of pages (this = table)
$('#display').html( event.type + " event triggered, now on page " + (options.page + 1) );
});
});</pre></div>
</td>
<td><a href="example-pager.html">Example</a></td>
</tr>
<tr id="pagercomplete">
<td><a href="#" class="permalink">pagerComplete</a></td>
<td>This event fires when the pager plugin has completed initialization (<span class="version">v2.18.1</span>), and its render of the table on the currently selected page. (v2.0.7).
<div class="collapsible">
<br>
<span class="label label-info">Note</span> In <span class="version">v2.18.1</span>, the "pagerComplete" event also fires off immediately after pager initialization.<br>
<br>
<pre class="prettyprint lang-js">$(function() {
// initialize the sorter
$("table")
.tablesorter()
// initialize the pager plugin
.tablesorterPager({
container: $("#pager")
})
// bind to pager events
.bind('pagerChange pagerComplete', function(event, options) {
// options = table.config.pager (pager addon)
// options = table.config (pager widget) - so use options.pager.page below
// c.totalPages contains the total number of pages
$('#display').html( event.type + " event triggered, now on page " + (options.page + 1) );
});
});</pre></div>
</td>
<td><a href="example-pager.html">Example</a></td>
</tr>
<tr id="pagerbeforeinitialized">
<td><a href="#" class="permalink">pagerBeforeInitialized</a></td>
<td>This event fires after all pager controls have been bound and set up but before the pager formats the table or loads any ajax data (v2.4.4).
<div class="collapsible">
<pre class="prettyprint lang-js">$(function() {
$("table")
// bind to pager initialized event BEFORE calling the ADDON
// or BEFORE initializing tablesorter when using the pager WIDGET*
.bind('pagerBeforeInitialized', function(event, options) {
// options = table.config.pager (pager addon)
// options = table.config (pager widget)
// event = event object; options = pager options
})
// initialize the sorter
.tablesorter()
// initialize the pager plugin
.tablesorterPager({
container: $("#pager")
});
});</pre><small>* Note: bind to all initialization events before initializing tablesorter; because most of the time, if bound after, the events will fire before the binding occurs</small>.</div>
</td>
<td></td>
</tr>
<tr id="pagerinitialized">
<td><a href="#" class="permalink">pagerInitialized</a></td>
<td>This event fires when the pager plugin has completed initialization (v2.4.4).
<div class="collapsible">
<pre class="prettyprint lang-js">$(function() {
$("table")
// bind to pager initialized event BEFORE calling the ADDON
// or BEFORE initializing tablesorter when using the pager WIDGET*
.bind('pagerInitialized', function(event, options) {
// options = table.config.pager (pager addon)
// options = table.config (pager widget) - so use options.pager.page below
// c.totalPages contains the total number of pages
$('#display').html( e.type + " event triggered, now on page " + (options.page + 1) );
})
// initialize the sorter
.tablesorter()
// initialize the pager plugin
.tablesorterPager({
container: $("#pager")
});
});</pre><small>* Note: bind to all initialization events before initializing tablesorter; because most of the time, if bound after, the events will fire before the binding occurs</small>.</div>
</td>
<td><a href="example-pager.html">Example</a></td>
</tr>
<tr id="pagemoved">
<td><a href="#" class="permalink">pageMoved</a></td>
<td>This event fires when the pager plugin begins to change to the selected page (v2.4.4).
<div class="collapsible">
This event may fire before the <code>pagerComplete</code> event when ajax processing is involved, or after the <code>pagerComplete</code> on normal use.
See <a href="https://github.com/Mottie/tablesorter/pull/153">issue #153</a>.
<pre class="prettyprint lang-js">$(function() {
// initialize the sorter
$("table")
.tablesorter()
// initialize the pager plugin
.tablesorterPager({
container: $("#pager")
})
// bind to pager events
.bind('pageMoved', function(event, options) {
// options = table.config.pager (pager addon)
// options = table.config (pager widget) - so use options.pager.page below
// c.totalPages contains the total number of pages
$('#display').html( event.type + " event triggered, now on page " + (options.page + 1) );
});
});</pre></div>
</td>
<td><a href="example-pager.html">Example</a></td>
</tr>
</tbody>
</table>
<a id="api"></a>
<h1>Tablesorter API</h1>
<div class="tip">
tablesorter has some useful internal variables & functions available through the API which can be used in custom coding, parsers and/or widgets.<br>
<h4>Variables</h4>
<span class="label label-info">TIP!</span> Click on the link in the variable column to reveal full details (or <a href="#" class="toggleAll">toggle</a>|<a href="#" class="showAll">show</a>|<a href="#" class="hideAll">hide</a> all) or double click to update the browser location.
</div>
<table class="api tablesorter-blue" data-sortlist="[[0,0]]">
<thead>
<tr>
<th class="setwidth">Variable</th>
<th>Type</th>
<th class="sorter-false">Description</th>
<th class="sorter-false">Link</th>
</tr>
</thead>
<tbody>
<tr id="variable-defaults">
<td><a href="#" class="permalink">$.tablesorter.defaults</a></td>
<td>Object</td>
<td>This object contains all of the default settings shown in the <a href="#Configuration">configuration</a> section.
<div class="collapsible">
<p>
Changing a defaults will cause all tables using the code to alter its default behavior without needing to include the options while initializing. For example, changing the default theme will cause all tables to use the new theme (make sure to include the css!).
</p>
<span class="label warning">Note</span>: If you wish to modify this object, make sure to either target the setting directly: <pre class="prettyprint lang-js">
// set the default directly
$.tablesorter.defaults.theme = 'myCustomTheme';</pre>
Or use jQuery extend (include <code>true</code> parameter for <a href="http://api.jquery.com/jQuery.extend/#jQuery-extend-deep-target-object1-objectN">more depth</a>): <pre class="prettyprint lang-js">
// Extend the object. Use `true` for more than one level of depth
$.extend( true, $.tablesorter.defaults, {
theme: 'myCustomTheme',
widgets: ['zebra', 'filter'],
widgetOptions: {
filter_placeholder: {
search: 'Find in column...',
select: 'Choose an option'
},
zebra: [ 'row-even', 'row-odd' ]
}
});</pre>
If you don't use one of the above methods, the other default settings will be removed and cause unexpected issues.
</div>
</td>
<td></td>
</tr>
<tr id="variable-parsers">
<td><a href="#" class="permalink">$.tablesorter.parsers</a></td>
<td>Array</td>
<td>This is an array of all parser objects added using the <a href="#function-addparser"><code>addParser</code></a> function.
<div class="collapsible">
<br>
If a specific parser needs to be retreived from this array, use the <a href="#function-getparserbyid"><code>getParserById</code></a> function.
</div>
</td>
<td></td>
</tr>
<tr id="variable-themes">
<td><span class="permalink">$.tablesorter.themes</span></td>
<td>Object</td>
<td>This is an object containing a list of specific class names to be applied to table elements. Please see the widget <a href="#widget-uitheme"><code>uitheme</code></a> option for more details. </td>
<td></td>
</tr>
<tr id="variable-widgets">
<td><a href="#" class="permalink">$.tablesorter.widgets</a></td>
<td>Array</td>
<td>This is an array of all widget objects added using the <a href="#function-addwidget"><code>addWidget</code></a> function.
<div class="collapsible">
<br>
If a specific widget needs to be retreived from this array, use the <a href="#function-getwidgetbyid"><code>getWidgetById</code></a> function.
</div>
</td>
<td></td>
</tr>
<tr id="variable-language">
<td><a href="#" class="permalink">$.tablesorter.language</a></td>
<td>Object</td>
<td>This object contains the phrases (in English by default) added to the <code>aria-label</code> on each header column (<span class="version updated">v2.24.4</span>).
<div class="collapsible">
<p>In <span class="version updated">v2.24.4</span>, <code>sortDisabled</code> was added to the language settings. It is added to disabled columns which may have a sort applied; so, instead of "nextAsc", "nextDesc" or "nextNone" being appended to the sort message, the "sortDisabled" content is added.</p>
This is how the object is set up:
<pre class="prettyprint lang-js">$.tablesorter.language = {
sortAsc : 'Ascending sort applied, ',
sortDesc : 'Descending sort applied, ',
sortNone : 'No sort applied, ',
sortDisabled : 'sorting is disabled', // added v2.24.4
nextAsc : 'activate to apply an ascending sort',
nextDesc : 'activate to apply a descending sort',
nextNone : 'activate to remove the sort'
};</pre>
So, as an example, in the following situation:
<ul>
<li>A table header is named "Account #"</li>
<li>This column has an ascending sort applied</li>
<li>The next click on the header will be a descending sort, which means:
<ul>
<li><code>sortInitialOrder</code> option has its default setting; so the sort order will switch from ascending to descending on the second click.</li>
<li>No <code>lockedOrder</code> is set within the <code>headers</code> option</li>
</ul>
</li>
</ul>
Then the label will be built as follows:
<pre class="prettyprint lang-js">// "Header Name" + $.tablesorter.language.sortAsc + $.tablesorter.language.nextDesc
"Account #: Ascending sort applied, activate to apply a descending sort"</pre>
If the next click were to reset the sort (<code>sortReset</code> applied), then the message would use <code>$.tablesorter.language.nextNone</code>.<br>
<br>
In <span class="version updated">v2.24.4</span>, if sorting is disabled but the column has a sort applied, the label will be built as follows:
<pre class="prettyprint lang-js">// "Header Name" + $.tablesorter.language.sortDesc + $.tablesorter.language.sortDisabled
"Account #: Descending sort applied, sorting is disabled"</pre>
Use this variable to change the language as follows:
<pre class="prettyprint lang-js">$(function() {
$.tablesorter.language = {
sortAsc : 'sorting from a to z, ',
sortDesc : 'sorting from z to a, ',
sortNone : 'not sorted, but ',
sortDisabled : 'sorting is disabled',
nextAsc : 'click to sort from a to z',
nextDesc : 'click to sort from z to a',
nextNone : 'click to clear the sort'
}
$('table').tablesorter();
});</pre>
</div>
</td>
<td>
<a href="example-widget-header-titles.html">1</a>
<a href="example-widget-toggle-tablesorter.html">2</a>
</td>
</tr>
<tr id="variable-instanceMethods">
<td><a href="#" class="permalink">$.tablesorter.instanceMethods</a></td>
<td>Object</td>
<td>This variable contains all instance methods of the config object. Added using <a href="#function-addInstanceMethods"><code>addInstanceMethods</code></a> function before table initialization (<span class="version">v2.21.0</span>).
<div class="collapsible">
<br>
<pre class="prettyprint lang-js">$.tablesorter.addInstanceMethods({
columnSum: function(colNumber) {
var sum = 0, tbodyIndex, normalizedRows, rowIndex;
// `this` refers to config object
for (tbodyIndex = 0; tbodyIndex < this.$tbodies.length; ++tbodyIndex) {
normalizedRows = this.cache[tbodyIndex].normalized;
for (rowIndex = 0; rowIndex < normalizedRows.length; ++rowIndex) {
sum += normalizedRows[rowIndex][colNumber];
}
}
return sum;
},
columnMean: function(colNumber) {
return this.columnSum(colNumber) / this.totalRows;
},
});
$('table').tablesorter();
c = $('table')[0].config;
console.log('sum of third column: ' + c.columnSum(2));
console.log('mean of third column: ' + c.columnMean(2));</pre>
</div>
</td>
<td></td>
</tr>
</tbody>
<!-- non-sorting tbody -->
<tbody id="functions-core" class="tablesorter-infoOnly">
<tr id="config">
<th class="nobold"><a href="#" class="permalink">core</a></th>
<th></th>
<th class="nobold">Access the table configuration variables (<code>config</code>) using any of these methods:
<div class="collapsible">
<br>
<pre class="prettyprint lang-js">// pure js, get the first table (zero index)
var config = document.getElementsByTagName('table')[0].config;
// or by table ID
var config = document.getElementById('mytable').config;
// using jQuery, get first table (zero index)
var config = $('table')[0].config;
// or from the jQuery data
var config = $('#mytable').data('tablesorter');
</pre>
</div>
</th>
<th></th>
</tr>
</tbody>
<tbody>
<tr id="variable-cache">
<td><a href="#" class="permalink">config.cache</a></td>
<td>Object</td>
<td>Internal list of table contents (<span class="version">v2.0.18</span>; <span class="version updated">v2.20.0</span> )
<div class="collapsible">
<br>
This object contains the following:<br>
<ul>
<li>tbody index (<strong>non-info block only</strong>, indexing now matches the <a href="#variable-tbodies"><code>config.$tbodies</code></a> variable; <span class="version updated">v2.20.0</span>)
<ul>
<li><code>colMax</code>
<ul>
<li>This contains an array of the absolute value maximum numerical value for each "numerically" parsed column per tbody.</li>
<li>Text columns will have an undefined value in this array.</li>
<li>Used when determining how to sort text within a numeric column.</li>
<li>Access it as follows: <pre class="prettyprint lang-js">// $('table')[0].config.cache[tbodyIndex].colMax[column];
// try this in the console for this page:
$('.tablesorter')[0].config.cache[0].colMax;
// result: [undefined × 3, 45, 153.19, 44.7, 100.9, 1169133120000]</pre></li>
</ul>
</li>
<li><code>normalized</code>
<ul>
<li>This contains an array of indexed table rows.</li>
<li>Within each row is an array of extracted, then parsed table contents for each column (plus one extra value; see the next comment).</li>
<li>It is important to note that the last value in the column array is <del>the original row index value</del>. This is used when resetting a column sort to its original unsorted order.</li>
<li>In <span class="version updated">v2.19.1</span>, the <code>raw</code> unparsed data was added to the row data.</li>
<li>In <span class="version updated">v2.16.0</span>, the last value in the column array is now an object which contains a jquery object of the row, index of the original unsorted order and a child array which contains raw html from any associated child row
<pre class="prettyprint lang-js">// $('table')[0].config.cache[tbodyIndex].normalized[row][column]
// try this in the console for this page:
$('.tablesorter')[0].config.cache[0].normalized[0];
/* result: ["a1", "bruce", "almighty", 45, 153.19, 44.7, 77, 979830720000, {
$row : jQuery.fn.jQuery.init[1], // row (jQuery object)
child : [], // child row raw html, if any
// raw unparsed data from the table cells - added v2.19.1
raw : ["A1", "Bruce", "Almighty", "45", "$153.19", "44.7%", "+77", "Jan 18, 2001 9:12 AM"],
order : 3 // original row index (unsorted)
}]
*/</pre>
to specifically target the extra row data, use this method:
<pre class="prettyprint lang-js">var config = $('.tablesorter')[0].config,
dataIndex = config.columns, // number of columns within the table
rowData = config.cache[tbodyIndex].normalized[row][ dataIndex ];</pre>
</li>
<li>Note that all text values will be in lower case if the <a href="#ignorecase"><code>ignoreCase</code></a> option is <code>true</code>.</li>
<li>This internal normalized content is what is actually sorted for maximum performance.</li>
</ul>
</li>
<li><code>row</code> (<span class="label label-danger">removed</span> in v2.16.0)
<ul>
<li>Well not removed, but moved into the row data, within the normalized section of the cache as described above.</li>
<li><del>This contains an array of jQuery row objects</del>.</li>
<li><del>These rows are never in sort order, and are used when updating the table after sorting the normalized content. The indexing of these rows is cross-referenced within the normalized values - the extra column value within the row array. Hopefully that makes sense</del>.</li>
</ul>
</li>
</ul>
</li>
</ul>
The <code>table.config.cache</code> variable is useful when writing widgets that need access to the parsed content.
</div>
</td>
<td></td>
</tr>
<tr id="variable-columns">
<td><a href="#" class="permalink">config.columns</a></td>
<td>Numeric</td>
<td>Internal count of the number of table columns in the header (<span class="version">v2.12</span>)
<div class="collapsible">
<br>
This number is stored as a length (one-based), and takes into account any <code>colspan</code> and <code>rowspan</code> within the table head.<br>
<br>
Note that the <code>table.config.columns</code> variable does not always correlate with the indexing of the headers stored within <a href="#variable-headers"><code>table.config.$headers</code></a> because of multiple rows and column or row spans.
</div>
</td>
<td></td>
</tr>
<tr id="variable-headercontent">
<td><a href="#" class="permalink">config.headerContent</a></td>
<td>Array</td>
<td>Internal list of each header's starting HTML (as text) (v2.8)
<div class="collapsible"><br>
This HTML snapshot is taken using the <a href="#variable-headers"><code>$headers</code></a> jQuery object, and done before the <a href="#headertemplate"><code>headerTemplate</code></a> is applied and before the <a href="#onrendertemplate"><code>onRenderTemplate</code></a> and <a href="#onrenderheader"><code>onRenderHeader</code></a> callbacks are executed.<br>
<br>
This list is used by the <code>$.tablesorter.restoreHeaders</code> function to restore the table headers when the <a href="#destroy"><code>destroy</code></a> method is executed.
</div>
</td>
<td></td>
</tr>
<tr id="variable-headerlist">
<td><a href="#" class="permalink">config.headerList</a></td>
<td>Array</td>
<td>Internal list of each header element as selected using jQuery selectors in the <a href="#selectorheaders"><code>selectorHeaders</code></a> option.
<div class="collapsible">
<br>
This list contains DOM elements (not jQuery objects of each table header cell like the <a href="#variable-headers"><code>$headers</code></a> variable) and is how the original version of tablesorter stored these objects.
<br>
It is not used in the current version of tablesorter, and is only left in place for backwards compatibility with widgets written for the original tablesorter plugin.
</div>
</td>
<td></td>
</tr>
<tr id="parsers">
<td><a href="#" class="permalink">config.parsers</a></td>
<td>Array</td>
<td>Internal list of all of the table's currently set parsers (objects copied from <a href="#variable-parsers"><code>$.tablesorter.parsers</code></a>). Here is a complete list of default parsers: (modified v2.18.0)
<div class="collapsible">
<br>
<table class="info"><tbody>
<tr><th><code>parser: false</code></th><td>disable parsing for this column (this also disables sorting & filtering for the column; <span class="version updated">v2.17.6</span>).</td></tr>
<tr><th><code>sorter: false</code></th><td>disable sort for this column.</td></tr>
<tr><th><code>sorter: "text"</code></th><td>Sort alpha-numerically.</td></tr>
<tr><th><code>sorter: "digit"</code></th><td>Sort numerically.</td></tr>
<tr><th><code>sorter: "currency"</code></th><td>Sort by currency value (supports "£$€¤¥¢").</td></tr>
<tr><th><code>sorter: "image"</code></th><td>Sort by image alt value (see <a href="#imgattr"><code>imgAttr</code></a> option; added in v2.18.0).</td></tr>
<tr><th><code>sorter: "ipAddress"</code></th><td>Sort by IP Address; <span class="label label-warning">Warning</span> This parser was moved to the <code>parser-network.js</code> file in <span class="version updated">v2.18.0</span>.</td></tr>
<tr><th><code>sorter: "url"</code></th><td>Sort by url.</td></tr>
<tr><th><code>sorter: "isoDate"</code></th><td>Sort by ISO date (YYYY-MM-DD or YYYY/MM/DD; these formats can be followed by a time).</td></tr>
<tr><th><code>sorter: "percent"</code></th><td>Sort by percent.</td></tr>
<tr><th><code>sorter: "usLongDate"</code></th><td>Sort by date (U.S. Standard, e.g. Jan 18, 2001 9:12 AM or 18 Jan 2001 9:12 AM (new in v2.7.4)).</td></tr>
<tr><th><code>sorter: "shortDate"</code></th><td>Sort by a shortened date (see <a href="#dateformat"><code>dateFormat</code></a>; these formats can also be followed by a time).</td></tr>
<tr><th><code>sorter: "time"</code></th><td>Sort by time (23:59 or 12:59 pm).</td></tr>
<tr><th><code>sorter: "metadata"</code></th><td>Sort by the sorter value in the metadata - requires the metadata plugin.</td></tr>
</tbody></table>
<p>Check out the <a href="#headers"><code>headers</code></a> option to see how to use these parsers in your table (example #1).</p>
Or add a header class name using "sorter-" plus the parser name (example #2 & #3), this includes custom parsers (example #4).
</div>
</td>
<td>
<a href="example-options-headers-digits-strings.html">1</a>
<a href="example-parsers-class-name.html">2</a>
<a href="example-option-built-in-parsers.html">3</a>
<a href="example-parsers.html">4</a>
</td>
</tr>
<tr id="variable-header-indexed">
<td><a href="#" class="permalink">config.$headerIndexed</a></td>
<td>Array</td>
<td>Internally stored Array of headers that represent each column (<span class="version">v2.21.0</span>)
<div class="collapsible">
<br>
The <code>table.config.$headers</code> variable contains ALL header cells, not all of which contain sorting information (data-attributes, class names or sorting information).
<p></p>
This variable targets the <em>last sortable header cell</em> in a particular column; unless an entire column is completely unsortable (checkbox column), then it just picks the last cell in that column.
<p></p>
To make that description less confusing, look at the HTML in the <a href="#variable-headers"><code>config.$headers</code></a> documentation, only the four middle rows (header-index 1-4) will be contained within this variable:
<pre class="prettyprint lang-js">// the resulting config.$headerIndexed for the HTML example in config.$headers will look like this:
console.log( table.config.$headerIndexed );
/* outputs : [
$('<th data-column="0">header-index 1</th>'),
$('<th data-column="1">header-index 2</th>'),
$('<th data-column="2">header-index 3</th>'),
$('<th data-column="3">header-index 4</th>')
] */</pre>
<p></p>
<span class="label label-warning">* NOTE *</span> This variable contains an array of jQuery objects, it is <em>not</em> a collection of jQuery objects, i.e.
<pre class="prettyprint lang-js">var $column = table.config.$headerIndexed[ 0 ]; // jQuery object returned
console.log( $column.hasClass('foo') ); // how to access information
var $headers = $( table.config.$headerIndexed ); // make a collection of jQuery objects
// then use collection manipulation functions
$headers.each(function() {
console.log( $(this).text() );
});</pre></div>
</td>
<td></td>
</tr>
<tr id="variable-headers">
<td><a href="#" class="permalink">config.$headers</a></td>
<td>jQuery Object</td>
<td>Internal list of <strong>all</strong> table header cells (<span class="version">v2.8</span>)
<div class="collapsible">
<p>
<span class="label label-info">*NOTE*</span> The header cells within rows with the <a href="#cssignorerow"><code>cssIgnoreRow</code></a> class (default is <code>"tablesorter-ignoreRow"</code> will not be included in this variable.</p>
<p>Header cells in not-ignored rows are targeted using the jQuery selector from the <a href="#selectorheaders"><code>selectorHeaders</code></a> option</p>
Please note that the headers cells are simply an array of targetted header cells and should not be targeted using a column index. For example, given the following table <code>thead</code> markup, the <code>header-index</code> counts the header <code>th</code> cells and does not actually match the <code>data-column</code> index when extra rows and/or <code>colspan</code> or <code>rowspan</code> are included in any of the header cells:
<pre class="prettyprint lang-html"><thead>
<tr>
<th colspan="4" data-column="0" class="sorter-false">header-index 0</th>
</tr>
<tr>
<th data-column="0">header-index 1</th>
<th data-column="1">header-index 2</th>
<th data-column="2">header-index 3</th>
<th data-column="3">header-index 4</th>
</tr>
<!-- the next row WILL NOT be included in the config.$headers variable -->
<tr class="tablesorter-ignoreRow">
<th colspan="2" data-column="0">This cell is not included in the config.$headers</th>
<th colspan="2" data-column="2">This cell is not included in the config.$headers</th>
</tr>
<tr>
<th colspan="2" data-column="0" class="sorter-false">header-index 5</th>
<th colspan="2" data-column="2" class="sorter-false">header-index 6</th>
</tr>
</thead></pre>
So, in the above example, to target the header cell in the second table column (<code>data-column</code> index of 1), use the following code: <code>table.config.$headers.filter('[data-column="1"]')</code> or <code>table.config.$headers.eq(2)</code>.<br>
<br>
The <code>table.config.$headers</code> variable is useful within callback functions or when writing widgets that target the table header cells.
</div>
</td>
<td></td>
</tr>
<tr id="variable-table-element">
<td><a href="#" class="permalink">config.table</a></td>
<td>DOM element</td>
<td>Internally stored DOM table element (<span class="version">v2.17.5</span>)
<div class="collapsible">
<br>
The <code>table.config.table</code> variable is useful when certain callback functions only pass the config object; originally you could use <code>config.$table[0]</code>, but this saves that small extra trouble.
</div>
</td>
<td></td>
</tr>
<tr id="variable-table">
<td><a href="#" class="permalink">config.$table</a></td>
<td>jQuery Object</td>
<td>Internally stored jQuery object of the table (<span class="version">v2.7.1</span>)
<div class="collapsible">
<br>
The <code>table.config.$table</code> variable is useful within callback functions or when writing widgets that target the table.
</div>
</td>
<td></td>
</tr>
<tr id="variable-sort-vars">
<td><a href="#" class="permalink">config.sortVars</a></td>
<td>Object</td>
<td>Internally stored object of column specific sort variables (<span class="version">v2.24.0</span>; <span class="version updated">v2.30.7</span>)
<div class="collapsible">
<br>
This object is defined as follows:<br>
<pre class="prettyprint lang-js">// $('table')[0].config.sortVars -> result
[{
// column 0
count: 0, // click count; used as index for order value
order: [ 0, 1, 2 ], // default sort (sortReset: true)
lockedOrder: false, // true if column order is locked (read only)
sortedBy: 'user'
},{
// ...
},{
// column n
count: 0, // click count; used as index for order value
order: [ 0, 1, 2 ], // default sort (sortReset: true)
lockedOrder: false, // true if column order is locked (read only)
sortedBy: 'sorton'
}]</pre>
<ul>
<li><code>count</code>
<ul>
<li>The initial value is <code>-1</code>.</li>
<li>The value is incremented each time the user clicks on a header cell; but it resets to zero once it reaches the end of the order array.</li>
</ul>
</li>
<li><code>order</code>
<ul>
<li>An array that contains the sort sequence for each column.</li>
<li><code>0</code> indicates an ascending sort.</li>
<li><code>1</code> indicates a descending sort.</li>
<li><code>0</code> indicates a reset sort (initial unsorted rows).</li>
<li>Locked sorts will contain either <code>[0, 0]</code> or <code>[1, 1]</code> determined by the lockedOrder setting.</li>
<li>Setting these values to <code>[2, 2]</code> will lock in an unsorted column, but the unsort arrows will still be visible; use a <code>"sorter-false"</code> class instead.</li>
<li>The values of this order can only be modified <em>after</em> tablesorter has initialized.</li>
</ul>
</li>
<li><code>lockedOrder</code>
<ul>
<li>See the <a href="#headers">lockedOrder</a> setting.</li>
<li>It's readonly because it is set during initialization and not used again (future use by a widget?)</li>
</ul>
</li>
<li><code>sortedBy</code>
These values are added to the header cell in a <code>data-sortedBy</code> attribute and may contain:
<ul>
<li><code>'user'</code> (renamed from <code>'mouseup'</code> event) when a column is sorted by a user.</li>
<li><code>'sort'</code> when a column is sorted by triggering a <a href="#sort">sort</a> event on the header.</li>
<li><code>'sorton'</code> when a column is sorted using the <a href="#sorton">sorton</a> method.</li>
<li><code>'sortAppend'</code> when a sorted column is added by the <a href="#sortappend">sortAppend</a> option.</li>
<li><code>'sortForce'</code> when a sorted column is added by the <a href="#sortforce">sortForce</a> option.</li>
</ul>
</li>
</ul>
</div>
</td>
<td></td>
</tr>
<tr id="variable-tbodies">
<td><a href="#" class="permalink">config.$tbodies</a></td>
<td>jQuery Object</td>
<td>Internally stored jQuery object of table non-info block tbodies (<span class="version">v2.7.1</span>)
<div class="collapsible">
<br>
jQuery object of sortable tbodies.<br>
<br>
<span class="label label-warning">Caution!</span> These tbodies are the ones without a class name from the <a href="#cssinfoblock"><code>cssInfoBlock</code></a> option, so the indexing of this jQuery object does not match the actual table tbody indexes.<br>
<br>
The <code>table.config.$tbodies</code> variable is useful within callback functions or when writing widgets that target the table.
</div>
</td>
<td></td>
</tr>
<tr id="variable-hasInitialized">
<td><a href="#" class="permalink">hasInitialized</a></td>
<td>Boolean</td>
<td>Boolean value indicating that tablesorter has been initialized on a table
<div class="collapsible">
<br>
This variable is not stored within the config, as the config would not be defined (an alternative method of determining if tablesorter has been initialized).<br>
<br>
Access it as follows: <code>$('table')[0].hasInitialized</code>. It is <code>true</code> while tablesorter is active on a table, and <code>false</code> if tablesorter was destroyed.
</div>
</td>
<td></td>
</tr>
<tr id="variable-totalrows">
<td><a href="#" class="permalink">config.totalRows</a></td>
<td>Numeric</td>
<td>This variable contains the total number of rows within the table, not including rows within info-only tbodies (<span class="version">v2.17.4</span>; <span class="version updated">v2.17.5</span>)
<div class="collapsible">
<br>
Access this internal value after tablesorter has initialized. It is also included as a variable in the <code>filterEnd</code> event so you can update an external count like this:
<pre class="prettyprint lang-js">$('table').bind('filterInit filterEnd', function(event, data) {
// use data.filteredRows or this.config.filteredRows
$('.filter-rows').html( data.filteredRows );
$('.total-rows').html( data.totalRows );
});</pre><hr>
If using the pager plugin or widget, the value returned from the <code>filterEnd</code> event will not be accurate, so you'll need to bind to the <code>pagerComplete</code> event instead:
<pre class="prettyprint lang-js">$('table').bind('filterInit filterEnd pagerComplete', function(event, data) {
// Note: data = table.config (filterEnd event); and data = table.config.pager (pagerComplete event)
// both objects contain data.filteredRows & data.totalRows
$('.filter-rows').html( data.filteredRows );
$('.total-rows').html( data.totalRows );
});</pre>
</div>
</td>
<td></td>
</tr>
</tbody>
<!-- non-sorting tbody -->
<tbody id="variables" class="tablesorter-infoOnly">
<tr id="widgetoptions-variables">
<th class="nobold"><a href="#" class="permalink">widgets</a></th>
<th></th>
<th class="nobold">Access the widgetOptions (<code>wo</code>) using any of these methods:
<div class="collapsible">
<br>
<pre class="prettyprint lang-js">// pure js, get the first table (zero index)
var wo = document.getElementsByTagName('table')[0].config.widgetOptions;
// or by table ID
var wo = document.getElementById('mytable').config.widgetOptions;
// using jQuery, get first table (zero index)
var wo = $('table')[0].config.widgetOptions;
// or from the jQuery data
var wo = $('#mytable').data('tablesorter').widgetOptions;
</pre>
</div>
</th>
<th></th>
</tr>
</tbody>
<tbody>
<tr id="variable-any-match">
<td><a href="#" class="permalink">wo.filter_$anyMatch</a></td>
<td>jQuery Object</td>
<td>Only available when the filter widget is active. This variable contains all external search inputs with <code>data-column="all"</code>, bound using the <a href="#function-bind-search"><code>bindSearch</code></a> function.
<div class="collapsible">
<br>
The <code>table.config.widgetOptions.filter_$anyMatch</code> variable contains one more more search inputs, and is dynamically updated if the <a href="#function-bind-search"><code>bindSearch</code></a> function is called; make sure to set the flag to force a new search so that the values of the altered filters is updated appropriately.
</div>
</td>
<td></td>
</tr>
<tr id="variable-filters">
<td><a href="#" class="permalink">config.$filters</a></td>
<td>jQuery Object</td>
<td>Only available when the filter widget is active. This variable contains all table cells within the filter row.
<div class="collapsible">
<br>
Use the <code>table.config.$filters</code> variable when access to filters is needed. Note! This variable contains the <strong>table cell</strong> and not the actual input because the <a href="#widget-filter-formatter"><code>filter_formatter</code></a> function allows adding other types of value selectors (e.g. jQuery UI slider).
</div>
</td>
<td></td>
</tr>
<tr id="variable-externalfilters">
<td><a href="#" class="permalink">wo.filter_$externalFilters</a></td>
<td>jQuery Object</td>
<td>Only available when the filter widget is active. This variable contains all external search inputs bound using the <a href="#function-bind-search"><code>bindSearch</code></a> function.
<div class="collapsible">
<br>
The <code>table.config.widgetOptions.filter_$externalFilters</code> variable contains an array of jQuery objects pointing to all external inputs, even if the <a href="#function-bind-search"><code>bindSearch</code></a> function is used multiple times.
</div>
</td>
<td></td>
</tr>
<tr id="variable-filter-initialized">
<td><span class="permalink">wo.filter_initialized</span></td>
<td>Boolean</td>
<td>Only available when the filter widget is active. This variable is <code>true</code> once the filter widget has initialized; it is undefined otherwise.</td>
<td></td>
</tr>
<tr id="variable-filteredrows">
<td><a href="#" class="permalink">config.filteredRows</a></td>
<td>Numeric</td>
<td>Only available when the filter widget is active. This variable contains the current number of filtered rows (<span class="version">v2.17.4</span>; <span class="version updated">v2.17.5</span>)
<div class="collapsible">
<br>
This internal value will show an accurate number of filtered rows; which means the count won't include any rows from "information-only" tbodies.<br>
<br>
Access this internal value at any time after the filter widget has initialized, or as a shortcut it is included as a variable in the <code>filterEnd</code> event so you can update an external count like this:
<pre class="prettyprint lang-js">$('table').bind('filterInit filterEnd', function(event, data) {
// use data.filteredRows or this.config.filteredRows
$('.filter-rows').html( data.filteredRows );
$('.total-rows').html( data.totalRows );
});</pre><hr>
If using the pager plugin or widget, the value returned from the <code>filterEnd</code> event will not be accurate, so you'll need to bind to the <code>pagerComplete</code> event instead:
<pre class="prettyprint lang-js">$('table').bind('filterInit filterEnd pagerComplete', function(event, data) {
// Note: data = table.config (filterEnd event); and data = table.config.pager (pagerComplete event)
// both objects contain data.filteredRows & data.totalRows
$('.filter-rows').html( data.filteredRows );
$('.total-rows').html( data.totalRows );
});</pre>
</div>
</td>
<td></td>
</tr>
<tr id="variable-sticky">
<td><a href="#" class="permalink">wo.$sticky</a></td>
<td>jQuery Object</td>
<td>Only available when the stickyHeaders widget (not the css3 version) is active.
<div class="collapsible">
<br>
The <code>table.config.widgetOptions.$sticky</code> variable contains a jQuery object pointing to a cloned table containing the sticky header. The table contained within this variable has a class name of <code>"containsStickyHeaders"</code> versus the original table with a class name of <code>"hasStickyHeaders"</code>.
</div>
</td>
<td></td>
</tr>
</tbody>
<!-- non-sorting tbody -->
<tbody class="tablesorter-infoOnly">
<tr id="pager-variables">
<th class="nobold"><a href="#" class="permalink">pager</a></th>
<th></th>
<th class="nobold">Access the pager options<sup><strong>†</strong></sup> (<code>p</code>) using any of these methods:
<div class="collapsible">
<br>
<pre class="prettyprint lang-js">// pure js, get the first table (zero index)
var p = document.getElementsByTagName('table')[0].config.pager;
// or by table ID
var p = document.getElementById('mytable').config.pager;
// using jQuery, get first table (zero index)
var p = $('table')[0].config.pager;
// or from the jQuery data
var p = $('#mytable').data('tablesorter').pager;
</pre>
<strong>†</strong> These methods are the same for both the pager addon and the pager widget.
<p></p>
<span class="label label-info">*NOTE*</span> This pager variable also contains all of the default pager option settings.
<p></p>
<span class="label label-warning">*NOTE*</span> When using the pager widget, changing a value within the <code>widgetOptions</code> for the pager may not update the pager as expected. The pager widget uses most of the values within <code>config.pager</code> instead of the pager <code>widgetOptions</code> after initialization.
</div>
</th>
<th></th>
</tr>
</tbody>
<tbody>
<tr id="variable-pager-container">
<td><a href="#" class="permalink">p.$container</a></td>
<td>jQuery Object</td>
<td>Contains a jQuery object pointing to a pager block(s).
<div class="collapsible">
<br>
The <code>table.config.pager.$container</code> variable is targeted using the pager <a href="#pager-container"><code>container</code></a> option and will have a class name of <code>"tablesorter-pager"</code> applied.<br>
<br>
The container(s) may include the pager navigation arrows, page size selector, page selector and/or output block; the contents are completely customizable and all components are optional.
</div>
</td>
<td></td>
</tr>
<tr id="variable-pager-goto">
<td><a href="#" class="permalink">p.$goto</a></td>
<td>jQuery Object</td>
<td>Contains a jQuery object pointing to an empty select within the pager block(s).
<div class="collapsible">
<br>
The <code>table.config.pager.$goto</code> variable is targeted using the pager <a href="#pager-cssgoto"><code>cssGoto</code></a> option.<br>
<br>
The contents of this select element are dynamically updated if the page size is changed or if the table gets filtered.
</div>
</td>
<td></td>
</tr>
<tr id="variable-pager-size-object">
<td><a href="#" class="permalink">p.$size</a></td>
<td>jQuery Object</td>
<td>Contains a jQuery object pointing to a select with the desired page size settings already in place.
<div class="collapsible">
<br>
The <code>table.config.pager.$size</code> variable is targeted using the pager <a href="#pager-csspagesize"><code>cssPageSize</code></a> option.<br>
<br>
The contents of this select element must be set up with the desired page size settings before initializing tablesorter.<br>
<br>
Also, because Internet Explorer does not appear to get the select value from the option text, please include a value attribute with all options. For example:
<pre class="prettyprint lang-html"><select class="pagesize">
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="40">40</option>
</select></pre>
</div>
</td>
<td></td>
</tr>
<tr id="variable-pager-cache-index">
<td><a href="#" class="permalink">p.cacheIndex</a></td>
<td>Array</td>
<td>Contains an array of zero-based row indexes of rows that currently displayed within the table.
<div class="collapsible">
<br>
For example, if you want to get the parsed values for the rows currently displayed within the pager, use the <code>table.config.pager.cacheIndex</code> variable as follows:
<pre class="prettyprint lang-js">var c = $('table')[0].config,
p = c.pager,
cache = c.cache[0].normalized,
cachedValues = [];
$.each( p.cacheIndex, function(i, v) {
// cache[v] will be an array of parsed values for each cell in selected row
cachedValues.push( cache[v] );
});</pre>
the <code>p.cacheIndex</code> variable get updated whenever the table is sorted, filtered or the pager changes pages or page size.
</div>
</td>
<td></td>
</tr>
<tr id="variable-pager-startrow">
<td><a href="#" class="permalink">p.startRow</a></td>
<td>Numeric</td>
<td>Contains a one-based index of the first row visible in the pager.
<div class="collapsible">
<br>
The <code>{startRow}</code> tag in the pager <a href="#pager-output"><code>output</code></a> option is replaced by this value; and it does not correspond to the row index within the cache.
</div>
</td>
<td></td>
</tr>
<tr id="variable-pager-endrow">
<td><a href="#" class="permalink">p.endRow</a></td>
<td>Numeric</td>
<td>Contains a one-based index of the last row visible in the pager.
<div class="collapsible">
<br>
The <code>{endRow}</code> tag in the pager <a href="#pager-output"><code>output</code></a> option is replaced by this value; and it does not correspond to the row index within the cache.
</div>
</td>
<td></td>
</tr>
<tr id="variable-pager-filteredpages">
<td><a href="#" class="permalink">p.filteredPages</a></td>
<td>Numeric</td>
<td>Contains the page count, determined by the page size setting, after the table is filtered. It equals the <code>totalPages</code> if no filters are applied.
<div class="collapsible">
<br>
The <code>{filteredPages}</code> tag in the pager <a href="#pager-output"><code>output</code></a> option is replaced by this value.
</div>
</td>
<td></td>
</tr>
<tr id="variable-pager-filteredrows">
<td><a href="#" class="permalink">p.filteredRows</a></td>
<td>Numeric</td>
<td>Contains the number of rows accessible by the pager after the table is filtered. It equals the <code>totalRows</code> if no filters are applied.
<div class="collapsible">
<br>
The <code>{filteredRows}</code> tag in the pager <a href="#pager-output"><code>output</code></a> option is replaced by this value.
</div>
</td>
<td></td>
</tr>
<tr id="variable-pager-page">
<td><a href="#" class="permalink">p.page</a></td>
<td>Numeric</td>
<td>Contains a zero-based index of the current page visible in the pager.
<div class="collapsible">
<br>
The <code>{page}</code> tag in the pager <a href="#pager-output"><code>output</code></a> option is replaced by this value.<br>
<br>
Initially, this value is set by either the pager <a href="#pager-page"><code>page</code></a> option or from local storage if the <a href="#save-pages"><code>savePages</code></a> option is <code>true</code>. It is then updated by user interaction with the page selector (targeted by the <a href="#pager-cssgoto"><code>cssGoto</code></a> option or programmically by the <a href="#pageset"><code>pageSet</code></a> or <a href="#pageandsize"><code>pageAndSize</code></a> method.
</div>
</td>
<td></td>
</tr>
<tr id="variable-pager-size">
<td><a href="#" class="permalink">p.size</a></td>
<td>Numeric</td>
<td>Contains the currently selected page size.
<div class="collapsible">
<br>
Initially, this value is set by either the pager <a href="#pager-size"><code>size</code></a> option or from local storage if the <a href="#save-pages"><code>savePages</code></a> option is <code>true</code>. It is then updated by user interaction with the size selector (targeted by the <a href="#pager-csspagesize"><code>cssPageSize</code></a> option or programmically by the <a href="#pagesize"><code>pageSize</code></a> or <a href="#pageandsize"><code>pageAndSize</code></a> method.
</div>
</td>
<td></td>
</tr>
<tr id="variable-pager-totalpages">
<td><a href="#" class="permalink">p.totalPages</a></td>
<td>Numeric</td>
<td>Contains the total page count as determined by the page size setting.
<div class="collapsible">
<br>
The <code>{totalPages}</code> tag in the pager <a href="#pager-output"><code>output</code></a> option is replaced by this value.
</div>
</td>
<td></td>
</tr>
<tr id="variable-pager-totalrows">
<td><a href="#" class="permalink">p.totalRows</a></td>
<td>Numeric</td>
<td>Contains the total number of rows within the table
<div class="collapsible">
<br>
The <code>{totalRows}</code> tag in the pager <a href="#pager-output"><code>output</code></a> option is replaced by this value.
</div>
</td>
<td></td>
</tr>
</tbody>
<!-- non-sorting tbody -->
<tbody id="pager-removed-variables" class="tablesorter-infoOnly">
<tr><th colspan="4">Removed Variables</th></tr>
</tbody>
<tbody>
<tr id="variable-extra-headers">
<td><a href="#" class="permalink alert">config.$extraHeaders</a></td>
<td>jQuery Object</td>
<td>Internal list of <strong>all</strong> extra table header cells (<span class="version">v2.16.2</span>; <span class="label label-danger">removed</span> v2.21.3)
<div class="collapsible">
<p>This variable was removed due to it causing memory leak issues. To now find extra headers use <a href="#namespace"><code>config.namespace</code></a> as follows:</p>
<pre class="prettyprint lang-js">$( config.namespace + '_extra_headers' )</pre>
<p>When the <a href="#function-bindevents"><code>bindEvents</code></a> function is used, the extra (external) header cells are added to this variable, and automatically updated with the table headers (<a href="#variable-headers"><code>config.$headers</code></a>).</p>
<p>So, when writing a custom widget that clones the table header, there is no longer a need to update the header class names, it's all done automatically.</p>
</div>
</td>
<td></td>
</tr>
<tr id="variable-extra-tables">
<td><a href="#" class="permalink alert">config.$extraTables</a></td>
<td>jQuery Object</td>
<td>Internal list of <strong>all</strong> extra (cloned) table elements (<span class="version">v2.19.0</span>; <span class="label label-danger">removed</span> v2.21.3)
<div class="collapsible">
<p>This variable was removed due to it causing memory leak issues. To find extra tables use <a href="#namespace"><code>config.namespace</code></a> as follows:</p>
<pre class="prettyprint lang-js">$( config.namespace + '_extra_table' )</pre>
<p>Some widgets need to duplicate parts of the original table to provide functionality (e.g. stickyHeaders, scroller). This saved variable will either not exist or contain a jQuery object pointing to the cloned table elements.</p>
<p>This variable was added for the uitheme widget to allow dynamic updating of themes to the original table as well as all cloned parts.</p>
</div>
</td>
<td></td>
</tr>
</tbody>
</table>
<div class="tip">
<h4>Functions</h4>
<span class="label label-info">TIP!</span> Click on the link in the function column to reveal full details (or <a href="#" class="toggleAll">toggle</a>|<a href="#" class="showAll">show</a>|<a href="#" class="hideAll">hide</a> all) or double click to update the browser location.
</div>
<table id="functions" class="api tablesorter-blue" data-sortlist="[[0,0]]">
<thead>
<tr>
<th class="setwidth">Function</th>
<th>Description</th>
</tr>
</thead>
<!-- non-sorting tbody -->
<tbody id="functions-core2" class="tablesorter-infoOnly">
<tr><th colspan="2">Core Functions</th></tr>
</tbody>
<tbody>
<tr id="function-fixcolumnwidth">
<td><a href="#" class="permalink">fixColumnWidth</a></td>
<td>This function adds a <code>colgroup</code> element to the table when <a href="#widthfixed"><code>widthFixed</code></a> is <code>true</code>.
<div class="collapsible"><br>
A new <code>colgroup</code> with <code>col</code> elements is only added if:
<ul>
<li><a href="#widthfixed"><code>widthFixed</code></a> is <code>true</code>.</li>
<li>A predefined <code>colgroup</code> element does not already exist in the table *.</li>
</ul>
* <span class="label label-info">Note</span> If a <code>colgroup</code> was added by the plugin, calling this function additional times will refresh the set widths<br>
<br>
Also, the <code>col</code> elements within the <code>colgroup</code> are set with a percentage width to dynamically maintain the fixed column width ratios.<br>
<br>
Use it as follows:
<pre class="prettyprint lang-js">$.tablesorter.fixColumnWidth( table );</pre>
<ul>
<li><code>table</code> - table DOM element (or jQuery object) of table.</li>
</ul>
</div>
</td>
</tr>
<tr id="function-processtbody">
<td><a href="#" class="permalink">processTbody</a></td>
<td>
This function detaches the targeted tbody from the DOM to allow faster manipulation of the tbody contents (v2.4).
<div class="collapsible">
Use it as follows:
<pre class="prettyprint lang-js">$.tablesorter.processTbody( table, $(tbody), getIt );</pre>
<ul>
<li><code>table</code> - table DOM element (or jQuery object) of table containing the tbody.</li>
<li><code>$(tbody)</code> - tbody jQuery object.</li>
<li><code>getIt</code> - Boolean flag (optional if <code>false</code>).</li>
</ul>
When calling the function, to get a tbody, set the <code>getIt</code> boolean parameter to <code>true</code> and the removed tbody is returned; setting this option to <code>false</code> or optionally not including it will restore the tbody.
<br>
Here is a basic example of how this function is used:
<pre class="prettyprint lang-js">var tbodyIndex, _tbody,
table = $('#my-table')[0],
tbodies = table.tBodies, // use table.config.$tbodies for all tbodies EXcluding information only tbodies
for (tbodyIndex = 0; tbodyIndex < tbodies.length; tbodyIndex++) {
// detach tbody from table
_tbody = $.tablesorter.processTbody( table, tbodies[tbodyIndex], true );
// do something magical to the tbody
_tbody.addClass('unicorn');
// restore tbody
$.tablesorter.processTbody( table, _tbody );
}</pre>
Please note that completely detaching the tbody was found to be a much quicker method of manipulating DOM elements than just hiding the tbody; this is especially true in older browsers.
</div>
</td>
</tr>
<tr id="function-isprocessing">
<td><a href="#" class="permalink">isProcessing</a></td>
<td>This function adds the processing (indeterminant loading icon) to specific or all header cells while processing table elements (v2.4).
<div class="collapsible"><br>
Use it as follows:
<pre class="prettyprint lang-js">$.tablesorter.isProcessing( table, toggle, $ths );</pre>
<ul>
<li><code>table</code> - table DOM element (or jQuery object) of table.</li>
<li><code>toggle</code> - Boolean flag.</li>
<li><code>$ths</code> - jQuery object of targeted header cells (optional; if excluded all header cells are targeted).</li>
</ul>
When calling the function, set the <code>toggle</code> option to add (<code>true</code>) or remove (<code>false</code>) process indicators. Include any specific header cells within the <code>$ths</code> variable with which to add the process indicator. When <code>$ths</code> is not defined and a sort is applied, the currently sorted header cells will show process indicators.<br>
<br>
All this function does is add or remove a class name of <code>"tablesorter-processing"</code> and the class name contained within the <a href="#cssprocessing"><code>cssProcessing</code> option</a>.<br>
<br>
Here is a basic example of how this function is used:
<pre class="prettyprint lang-js">$('table').bind('sortBegin sortEnd', function(event, table) {
// this is included with the basic functionality of tablesorter
$.tablesorter.isProcessing( this, event === 'sortBegin' );
});</pre>
Please note that currently the processing icons do not animate (see <a href="https://github.com/Mottie/tablesorter/issues/158">issue #158</a>). This is due to javascript being a single-threaded, meaning it only does one task at a time, and maximizing the sorting script. So lots of processing is needed to sort & rebuild the table and thus it has no time for animation. If someone knows of a better solution, please share!
</div>
</td>
</tr>
<tr id="function-cleartablebody">
<td><a href="#" class="permalink">clearTableBody</a></td>
<td>This function empties ALL of the table tbodies (<span class="version updated">v2.17.2</span>).
<div class="collapsible"><br>
Use it as follows:
<pre class="prettyprint lang-js">$.tablesorter.clearTableBody( table );</pre>
<ul>
<li><code>table</code> - table DOM element (or jQuery object) of table.</li>
</ul>
Please note that this function uses jQuery <code>empty()</code>. All data & event handlers are removed. No where within the tablesorter script or included widgets is this function used, it is left intact for backwards compatibility.
</div>
</td>
</tr>
<tr id="function-bindevents">
<td><a href="#" class="permalink">bindEvents</a></td>
<td>This function adds header event listeners to the targeted cells (v2.8; <span class="version updated">v2.16.2</span>).
<div class="collapsible"><br>
Use it as follows:
<pre class="prettyprint lang-js">$.tablesorter.bindEvents( table, $headers );</pre>
<ul>
<li><code>table</code> - table DOM element (or jQuery object) of table.</li>
<li><code>$headers</code> - jQuery object of targeted cells.</li>
</ul>
This function allows you to bind the same header event listeners to external headers cells (usually clones of the original table). This includes the triggered <code>sort</code> event, left click (only) to sort, ignoring long clicks (> 250ms), pressing enter to trigger a sort (must have focus and a <code>tabindex</code> attribute) and cancelling selection of text (if the option is set).<br>
<br>
To ensure the columns match the original table, include <code>data-column</code> attributes pointing to the desired column.<br>
<br>
Here is a basic example of how this function is used:
<pre class="prettyprint lang-js">var $table = $('table'),
// make a copy of the table
$clonedTable = $table.clone().addClass('clonedTable').insertAfter($table);
// remove stuff we don't need in the clone
$clonedTable.find('tfoot,tbody').remove();
// bind events to the cloned headers
$.tablesorter.bindEvents( $table, $clonedTable.find('th') );</pre>
In <span class="version">v2.16.2</span>, this function now saves all extra (external) headers to the <a href="#variable-extra-headers"><code>config.$extraHeaders</code></a> variable which allows the plugin to automatically update the sort status.
</div>
</td>
</tr>
<tr id="function-restoreheaders">
<td><a href="#" class="permalink">restoreHeaders</a></td>
<td>This function restores the table headers cells with their original content (v2.8).
<div class="collapsible"><br>
The original header cell content is saved, within the <a href="#variable-headercontent"><code>headerContent</code></a> variable array, before the <a href="#headertemplate"><code>headerTemplate</code></a> is applied and before the <a href="#onrendertemplate"><code>onRenderTemplate</code></a> and <a href="#onrenderheader"><code>onRenderHeader</code></a> callbacks are executed.<br>
<br>
Use it as follows:
<pre class="prettyprint lang-js">$.tablesorter.restoreHeaders( table );</pre>
<ul>
<li><code>table</code> - table DOM element (or jQuery object) of table.</li>
</ul>
Please note that only header cells that still contain a div with a class name of <code>tablesorter-header-inner</code> will have their contents restored; it assumes that the contents have already been restored.
</div>
</td>
</tr>
<tr id="function-destroy">
<td><a href="#" class="permalink">destroy</a></td>
<td>This function completely removes tablesorter, including all widgets, associated data & event handlers from the table (v2.3.2).
<div class="collapsible"><br>
Use it as follows:
<pre class="prettyprint lang-js">$.tablesorter.destroy( table, removeClasses, callback );</pre>
<ul>
<li><code>table</code> - table DOM element (or jQuery object) of table.</li>
<li><code>removeClasses</code> - Boolean flag</li>
<li><code>callback</code> - Function executed once tablesorter has been removed.</li>
</ul>
When calling the function, set the <code>removeClasses</code> option to <code>true</code> to include removing of the <code>"tablesorter"</code> class name, tablesorter theme name (e.g. <code>"tablesorter-blue"</code>) and the class name applied by the <a href="#tableclass"><code>tableClass</code> option</a>. The callback function only provides a <code>table</code> (DOM element only) parameter.<br>
<br>
Here is a basic example of how this function is used:
<pre class="prettyprint lang-js">$.tablesorter.destroy( table, true, function(table) {
alert('tablesorter has been removed! No sort for you!');
});</pre>
Please note that only header cells that still contain a div with a class name of <code>tablesorter-header-inner</code> will have their contents restored; it assumes that the contents have already been restored.
</div>
</td>
</tr>
<tr id="function-sortnatural">
<td><a href="#" class="permalink">sortNatural</a></td>
<td>This function sorts the a & b parameter using a natural sort (v2.12; <span class="version updated">v2.28.13</span>).
<div class="collapsible"><br>
Access it as follows:
<pre class="prettyprint lang-js">$.tablesorter.sortNatural(a, b);</pre>
<ul>
<li><code>a</code> - string.</li>
<li><code>b</code> - string to compare.</li>
</ul>
Here is a basic example of how this function is used:
<pre class="prettyprint lang-js">var myArray = [ '1a', '10a', '2a', '2b' ];
// result: ["1a", "2a", "2b", "10a"]
myArray.sort(function(a,b) { return $.tablesorter.sortNatural(a, b); });</pre>
<del>Please note that this natural sort function only accepts strings (added v2.0.6; renamed v2.12)</del>.<br>
As of <span class="version updated">v2.28.13</span>, the natural sort function will convert all values into strings.
</div>
</td>
</tr>
<tr id="function-sorttext">
<td><a href="#" class="permalink">sortText</a></td>
<td>This function sorts the a & b parameter using a basic sort (renamed v2.12).
<div class="collapsible"><br>
Access it as follows:
<pre class="prettyprint lang-js">$.tablesorter.sortText(a, b);</pre>
<ul>
<li><code>a</code> - string.</li>
<li><code>b</code> - string to compare.</li>
</ul>
Here is a basic example of how this function is used:
<pre class="prettyprint lang-js">var myArray = [ '1a', '10a', '2a', '2b' ];
// result: ["10a", "1a", "2a", "2b"]
myArray.sort(function(a,b) { return $.tablesorter.sortText(a, b); });</pre>
</div>
</td>
</tr>
<tr id="function-replaceaccents">
<td><a href="#" class="permalink">replaceAccents</a></td>
<td>This function replaces basic accented characters to better sorting & filtering of table contents (v2.2).
<div class="collapsible"><br>
Use it as follows:
<pre class="prettyprint lang-js">$.tablesorter.replaceAccents(string);</pre>
<ul>
<li><code>string</code> - a string to process & replace accented characters.</li>
</ul>
Here is a basic example of how this function is used:
<pre class="prettyprint lang-js">$.tablesorter.replaceAccents("áàâãä"); // result: "aaaaa"</pre>
This function is used when the <a href="#sortlocalecompare"><code>sortLocaleCompare</code></a> option is set to <code>true</code>. Please refer to the option and <a href="example-locale-sort.html">the demo</a> for more details on the defaults values and how to add more accented characters.
</div>
</td>
</tr>
<tr id="function-isvalueinarray">
<td><a href="#" class="permalink">isValueInArray</a></td>
<td>This function returns a zero-based index value of the position of the value within the array, otherwise it returns -1 (Modified <span class="version updated">v2.15.6</span>).
<div class="collapsible"><br>
Use it as follows:
<pre class="prettyprint lang-js">$.tablesorter.isValueInArray(value, array);</pre>
<ul>
<li><code>value</code> - value to find within the array.</li>
<li><code>array</code> - array (sortList) to search for the value.</li>
</ul>
Sadly, this function has limited usefulness outside of tablesorter. It is only meant to search a <code>sortList</code> array and determine if a column (value) is already contained within it. Here is a basic example of how this function is used:
<pre class="prettyprint lang-js">var sortList = [ [1,0], [2,0], [0,0] ];
// result: 1
$.tablesorter.isValueInArray(2, sortList);</pre>
After <span class="version">v2.15.6</span>, this function returns a zero-based index of the position of the value within the array parameter, or -1 if the value is not in the array. Previously, this function returned a boolean value of <code>true</code> if the value was contained within the array, or <code>false</code> if not.
</div>
</td>
</tr>
<tr id="function-addparser">
<td><a href="#" class="permalink">addParser</a></td>
<td>This function allows the adding of custom parser scripts to the tablesorter core.
<div class="collapsible"><br>
Access it as follows:
<pre class="prettyprint lang-js">$.tablesorter.addParser(myParser);</pre>
<ul>
<li><code>myParser</code> - object containing parser code.</li>
</ul>
The <code>myParser</code> object must contain a proper template. The template must include an <code>id</code>, <code>is</code>, <code>format</code> and <code>type</code> blocks. Please refer to the <a href="example-parsers.html">writing custom parsers</a> demo page for more details & an example.
</div>
</td>
</tr>
<tr id="function-addInstanceMethods">
<td><a href="#" class="permalink">addInstanceMethods</a></td>
<td>This function allows to add custom methods for config object (<span class="version">v2.21.0</span>).
<div class="collapsible"><br>
Access it as follows:
<pre class="prettyprint lang-js">$.tablesorter.addInstanceMethods(methods);</pre>
<ul>
<li><code>methods</code> - an object containing methods to be added, indexed by method names. These methods can use config object by refering <code>this</code>.</li>
</ul>
Take a look at <a href="#variable-instanceMethods">instanceMethods</a> variable description for more details.
</div>
</td>
</tr>
<tr id="function-getparserbyid">
<td><a href="#" class="permalink">getParserById</a></td>
<td>This function returns the named parser object.
<div class="collapsible"><br>
Access it as follows:
<pre class="prettyprint lang-js">$.tablesorter.getParserById(name);</pre>
<ul>
<li><code>name</code> - the name (or id) of the parser.</li>
</ul>
Use this function as follows:
<pre class="prettyprint lang-js">var parser = $.tablesorter.getParserById("currency"),
value = parser.format('100%'); // returns 100 (number type, not a string)</pre>
</div>
</td>
</tr>
<tr id="function-haswidget">
<td><a href="#" class="permalink">hasWidget</a></td>
<td>This function allows the checking to see if a widget is installed (<span class="version">v2.17.4</span>).
<div class="collapsible"><br>
Access it as follows:
<pre class="prettyprint lang-js">$.tablesorter.hasWidget( table, 'mywidget');</pre>
<ul>
<li><code>table</code> - table element or jQuery object of the selected table.</li>
<li><code>'mywidget'</code> - ID of the widget to check.</li>
</ul>
This function returns a <code>boolean</code> value, where <code>true</code> means the widget is currently installed and active; and <code>false</code> means the widget is not installed.<br>
<br>
Use this function as follows:
<pre class="prettyprint lang-js">$.tablesorter.hasWidget( $('table'), 'zebra' ); // true</pre>
</div>
</td>
</tr>
<tr id="function-addwidget">
<td><a href="#" class="permalink">addWidget</a></td>
<td>This function allows the adding of custom widget scripts to the tablesorter core (<span class="version updated">v2.19.0</span>).
<div class="collapsible">
<br>
In <span class="version updated">v2.19.0</span>, a <code>"refreshing"</code> parameter was added to the <code>remove</code> widget function to indicate that the widget will be refreshed so it will only be temporarily removed (see <a href="example-widgets.html">this demo</a> for more details).<br>
<br>
Access it as follows:
<pre class="prettyprint lang-js">$.tablesorter.addWidget(myWidget);</pre>
<ul>
<li><code>myWidget</code> - object containing widget code.</li>
</ul>
The <code>myWidget</code> object must contain a proper template. The template must include an <code>id</code> and <code>format</code> blocks. The <code>priority</code>, <code>options</code>, <code>init</code> and <code>remove</code> blocks are optional.<br>
<br>
Please refer to the <a href="example-widgets.html">writing custom widgets</a> demo page for more details & an example.
</div>
</td>
</tr>
<tr id="function-getwidgetbyid">
<td><a href="#" class="permalink">getWidgetById</a></td>
<td>This function returns the named widget object.
<div class="collapsible"><br>
Access it as follows:
<pre class="prettyprint lang-js">$.tablesorter.getWidgetById(name);</pre>
<ul>
<li><code>name</code> - the name (or id) of the widget.</li>
</ul>
Use this function as follows:
<pre class="prettyprint lang-js">var widget = $.tablesorter.getWidgetById("saveSort"),
table = $('table')[0];
// apply save sort widget to a table; but it will get removed if the refreshWidgets method
// is triggered, unless the table.config.widgets array contains this widget name/id
widget.format( table, table.config, table.config.widgetOptions );</pre>
</div>
</td>
</tr>
<tr id="function-applywidget">
<td><a href="#" class="permalink">applyWidget</a></td>
<td>This function applys (refreshes) all currently selected widgets on a table (<span class="version updated">v2.16.0</span>; <span class="version updated">v2.19.0</span>).
<div class="collapsible"><br>
Use it as follows:
<pre class="prettyprint lang-js">$.tablesorter.applyWidget( table, init, callback );</pre>
<ul>
<li><code>table</code> - table DOM element (or jQuery object) of table.</li>
<li><code>init</code> - optional, boolean initialization flag.</li>
<li><code>callback</code> - optional, a function executed after all widgets have been applied; the only parameter is <code>table</code> (<span class="version">v2.19.0</span>).</li>
</ul>
The <code>init</code> flag is only set to <code>true</code> to extend the default option values from the widget options block. If the widget(s) have already been applied to the table, just leave this parameter undefined.<br>
<br>
This function is called when the <a href="#applywidgets">applyWidgets</a> method is triggered.
</div>
</td>
</tr>
<tr id="function-refreshwidgets">
<td><a href="#" class="permalink">refreshWidgets</a></td>
<td>This function removes, then reapplies all currently selected widgets on a table (v2.4; <span class="version updated">v2.19.0</span>).
<div class="collapsible">
<br>
In <span class="version updated">v2.19.0</span>, this function was modified to internally use the <a href="#function-removewidget">removeWidget</a> function & a <a href="#refreshcomplete"><code>"refreshComplete"</code></a> event is now triggered upon completion.<br>
<br>
Use it as follows:
<pre class="prettyprint lang-js">$.tablesorter.refreshWidgets( table, doAll, dontapply );</pre>
<ul>
<li><code>table</code> - table DOM element (or jQuery object) of table.</li>
<li><code>doAll</code> - optional, boolean flag.</li>
<li><code>dontapply</code> - optional, boolean flag.</li>
</ul>
The <code>doAll</code> flag is set to <code>true</code> if all widgets contained with the global <a href="#variable-widgets"><code>$.tablesorter.widgets</code></a> array are to be removed.<br>
When <code>doAll</code> is <code>false</code>, only widgets <em>not contained</em> within the <code>config.widget</code> option are removed; then if the <code>dontapply</code> flag is <code>false</code>, the widgets named in that option are reapplied (without removing them).<br>
<br>
This function is called when the <a href="#refreshwidgets">refreshWidgets</a> method is triggered.
</div>
</td>
</tr>
<tr id="function-removewidget">
<td><a href="#" class="permalink">removeWidget</a></td>
<td>This function removes selected widgets (<span class="version">v2.19.0</span>).
<div class="collapsible"><br>
Use it as follows:
<pre class="prettyprint lang-js">$.tablesorter.removeWidget( table, names, refreshing );</pre>
<ul>
<li><code>table</code> - table DOM element (or jQuery object) of table.</li>
<li><code>names</code> - string (space or comma separated widget names), an array of widget names, or if <code>true</code> all installed widgets are removed.</li>
<li><code>refreshing</code> - if <code>true</code>, the widget name will not be removed from the <a href="#widgets"><code>widgets</code></a> option; any other setting and the name will be removed.</li>
</ul>
This function is used by the <a href="#function-refreshwidgets">refreshWidgets</a> function (<span class="version">v2.19.0</span>).
</div>
</td>
</tr>
<tr id="function-getcolumndata">
<td><a href="#" class="permalink">getColumnData</a></td>
<td>This function returns the column data from an object based on a column index or classname/id (<span class="version updated">v2.21.1</span>).
<div class="collapsible">
<br>
Use it as follows:
<pre class="prettyprint lang-js">$.tablesorter.getColumnData( table, object, key );</pre>
<ul>
<li><code>table</code> - table DOM element (or jQuery object).</li>
<li><code>object</code> - object containing zero-based column indexes or column class names as a key (e.g. <code>table.config.headers</code> or <code>table.config.widgetOptions.filter_functions</code>; any data found as the value (of the <code>key : value</code> pair) will be returned.</li>
<li><code>key</code> - key to be Object key; this can be a zero-based column index or header class name/id.</li>
</ul>
As a full example, say you have a header cell with a class name of <code>"event"</code>. And you want to use the <code>textExtraction</code> function for that column, then you would use this function as follows:
<pre class="prettyprint lang-js">var table = $('table')[0],
textExtractionFunction = $.tablesorter.getColumnData( table, table.config.textExtraction, ".event" );</pre>
The <code>".event"</code> key can be replaced with a zero-based column index, if the <code>textExtraction</code> option is set up using indexes.
<p></p>
This function is sometimes used in conjunction with the <code>getData</code> function. This function is called first because the getData function uses the result in the <code>configHeaders</code> parameter - the <code>config.headers</code> option result from this function would be an object and not a function.
</div>
</td>
</tr>
<tr id="function-getcolumntext">
<td><a href="#" class="permalink">getColumnText</a></td>
<td>This utility function returns the entire column text (raw and parsed) as well as other data (<span class="version">v2.21.4</span>; <span class="updated version">v2.24.0</span>).
<div class="collapsible">
<br>
Use it as follows:
<pre class="prettyprint lang-js">$.tablesorter.getColumnText( table, column, callback, rowFilter );</pre>
<ul>
<li><code>table</code> - table DOM element (or jQuery object).</li>
<li><code>column</code> - zero-based column index or <code>'all'</code>.</li>
<li><code>callback</code> - callback function that is called while obtaining data for each cell within the specified column.</li>
<li><code>rowFilter</code> - can be a jQuery selector, function or element to allow targeting specific rows (e.g. <code>":visible"</code> or <code>":not(.child-row)"</code>); this parameter is used in a jQuery <code><a class="external" href="http://api.jquery.com/is/">.is()</a></code> function (<span class="version">v2.24.0</span>).</li>
</ul>
When using the callback, there is only one argument (object) passed to this function; it contains the following:
<ul>
<li><code>tbodyIndex</code> - the tbody zero-based index of the current cell.</li>
<li><code>rowIndex</code> - the row zero-based index of the current cell.</li>
<li><code>$row</code> - a jQuery object targeting the current row being processed.</li>
<li><code>$cell</code> - a jQuery object targeting the curretn cell being processed.</li>
<li><code>parsed</code> - parsed text of the current cell.</li>
<li><code>raw</code> - raw (unparsed) text of the current cell.</li>
</ul>
As an example, say you want to make the text of all cells with a value greater than 20 red (assuming the 'red' class name is defined in css). Do it as follows:
<pre class="prettyprint lang-js">var table = $('table')[0];
// targeting the 4th column (zero-based index)
$.tablesorter.getColumnText( table, 3, function( data ) {
if ( data.parsed > 20 ) {
data.$cell.addClass('red');
}
});</pre>
In this example, the goal is to get data from rows visible after filtering. When the callback returns <code>false</code>, that row/cell data will not be included in the resulting data:
<pre class="prettyprint lang-js">var table = $('table')[0],
// getting data from ALL columns, we're just skipping filtered out rows (rows with a "filtered" class)
result = $.tablesorter.getColumnText( table, 'all', function( data ) {
return !data.$row.hasClass('filtered');
});
// let's just assume this example is only showing filter matching rows (rows without a "filtered" class ;)
// result = {
// raw : [ [ 'r1c1', 'r1c2', ..., 'r1cN' ], [ 'r2c1', 'r2c2', ..., 'r2cN' ] ..., [ 'rNc1', 'rNc2', ..., 'rNcN' ] ],
// parsed : [ [ 'r1c1', 'r1c2', ..., 'r1cN' ], [ 'r2c1', 'r2c2', ..., 'r2cN' ] ..., [ 'rNc1', 'rNc2', ..., 'rNcN' ] ],
// $cell : [ [ $r1c1, $r1c2, ..., $r1cN ], [ $r2c1, $r2c2, ..., $r2cN ] ..., [ $rNc1, $rNc2, ..., $rNcN ] ]
// }
</pre>
If the callback isn't used, the function will return the cummulated data for the column (it does not include all of the parameters available within the callback function):
<pre class="prettyprint lang-js">var table = $('table')[0],
// targeting the 4th column (zero-based index)
columnText = $.tablesorter.getColumnText( table, 3 );
// columnText = {
// raw : [ 'cell1', 'cell2', ..., 'celln' ],
// parsed : [ 'cell1', 'cell2', ..., 'celln' ],
// $cell : [ $cell1, $cell2, ..., $celln ]
// }
</pre>
When using the filter widget, you can ignore filtered rows using the following code:
<pre class="prettyprint lang-js">var table = $('table')[0],
// targeting the 4th column (zero-based index); callback function is an empty string & therefore ignored
columnText = $.tablesorter.getColumnText( table, 3, '', ':not(.filtered)' );
// columnText = {
// raw : [ 'cell1', 'cell2', ..., 'celln' ],
// parsed : [ 'cell1', 'cell2', ..., 'celln' ],
// $cell : [ $cell1, $cell2, ..., $celln ]
// }
</pre>
All of these methods of gathering column data might be useful for custom widgets, etc.
<p></p>
<span class="label label-warning">* NOTE *</span> All currently available widgets that gather data from a column will be <em>updated to use this function in v2.22.0</em>.
</div>
</td>
</tr>
<tr id="function-getdata">
<td><a href="#" class="permalink">getData</a></td>
<td>This functions gets the sorter, string, empty, etc options for each column from jQuery data, metadata, header option or header class name ("sorter-false") (v2.1.16).
<div class="collapsible"><br>
priority = jQuery data > meta > headers option > header class name<br>
<br>
Use it as follows:
<pre class="prettyprint lang-js">$.tablesorter.getData(headerCell, configHeaders, key);</pre>
<ul>
<li><code>headerCell</code> - table DOM element (or jQuery object) of targeted header cell.</li>
<li><code>configHeaders</code> - table.config.headers option for the current column.</li>
<li><code>key</code> - get value for this option name, e.g. "sorter".</li>
</ul>
If the value of the "sorter" option is needed for a column, set the <code>key</code> to "sorter" and this function will return the set value, e.g. <code>false</code>, <code>digit</code>, <code>currency</code> etc.<br>
Use this function as follows:
<pre class="prettyprint lang-js">var column = 2,
config = $('table')[0].config,
headerCell = config.$headers.filter('[data-column="' + column + '"]');
// e.g. returns "false" if the header cell has the "sorter-false" class name
$.tablesorter.getData( headerCell, config.headers[column], "sorter" );</pre>
The reason there is a priority is because that is the order in which the values are searched, only the first (higher priority) value is returned.
</div>
</td>
</tr>
<tr id="function-formatfloat">
<td><a href="#" class="permalink">formatFloat</a></td>
<td>This function converts a number string into a number type.
<div class="collapsible"><br>
Use it as follows:
<pre class="prettyprint lang-js">$.tablesorter.formatFloat(string, table);</pre>
<ul>
<li><code>string</code> - a string possibly containing a number.</li>
<li><code>table</code> - table DOM element (or jQuery object) of table (optional; required for non U.S. formatting).</li>
</ul>
If <code>string</code> is empty, not a string type, or not a number (after processing), the string itself is returned.<br>
If <code>table</code> is not provided, the format float function will default to U.S. number formatting. The reason a <code>table</code> parameter is needed is to check the value of the <a href="#usnumberformat"><code>usNumberFormat</code></a> option.<br>
<br>
This function uses the <a href="#usnumberformat"><code>usNumberFormat</code></a> option to determine if either commas or decimals are removed before converting the value within the <code>string</code> parameter into a number type variable. This function does not use the <a href="#function-isdigit"><code>$.tablesorter.isDigit</code></a> function.<br>
<br>
Any numbers wrapped within parentheses are converted into negative numbers; but any other symbols (e.g. currency) are not removed and will cause this function to determine the string as a non-number (e.g. "$1.25" will be returned as a string).<br>
<br>
Use this function as follows:
<pre class="prettyprint lang-js">// result: -2345.67 if usNumberFormat option is true
$.tablesorter.formatFloat( "(2,345.67)", table );</pre>
</div>
</td>
</tr>
<tr id="function-isdigit">
<td><a href="#" class="permalink">isDigit</a></td>
<td>This function determines if a string contains a number after removing commas, periods, quotes and spaces.
<div class="collapsible"><br>
Use it as follows:
<pre class="prettyprint lang-js">$.tablesorter.isDigit(string);</pre>
<ul>
<li><code>string</code> - a string possibly containing a number.</li>
</ul>
This function will return a boolean value of <code>true</code> if the <code>string</code> parameter contains a number after all commas, decimals, quotes and spaces are removed, and still allow plus or minus signs, or the number wrapped in parenthesis (negative values).<br>
<br>
Use this function as follows:
<pre class="prettyprint lang-js">// boolean value of true returned
$.tablesorter.isDigit( "(2,345.67)" );</pre>
</div>
</td>
</tr>
<tr id="function-computecolumnindex">
<td><a href="#" class="permalink">computeColumnIndex</a></td>
<td>Adds the correct <code>data-column</code> indexing to all rows passed to this function (<span class="version">v2.16</span>; <span class="version updated">v2.25.0</span>).
<div class="collapsible">
<p>In <span class="version">v2.25.0</span>, if a <code>config</code> parameter is included, this function will only add a "data-column" attribute to cells where their internal <code>cellIndex</code> doesn't match its actual column index. This does not apply to internal usage where a "data-column" attribute is set on all header & footer cells.</p>
Use it as follows:
<pre class="prettyprint lang-js">// In v2.25.0, if a config parameter is included "data-columns" are not added
// to cells where their cellIndex and calculated column index match
$.tablesorter.computeColumnIndex($rows, config);</pre>
<ul>
<li><code>$rows</code> - jQuery object of rows in which to add data-column indexes.</li>
<li><code>config</code> - this is the <code>table.config</code> (table configuration variables) object.</li>
</ul>
Example result (without including <code>config</code>):<pre class="prettyprint lang-html"><tr>
<td colspan="2" data-column="0">r0c0</td>
<td data-column="2">r0c2</td>
</tr>
<tr>
<td data-column="0">r1c0</td>
<td data-column="1">r1c1</td>
<td data-column="2">r1c2</td>
</tr></pre>
Example result (including <code>config</code>):<pre class="prettyprint lang-html"><tr>
<td colspan="2">r0c0</td> <!-- data-column="0" is not included because it matches the cellIndex property -->
<td data-column="2">r0c2</td>
</tr>
<tr>
<td>r1c0</td>
<td>r1c1</td>
<td>r1c2</td>
</tr></pre>
</div>
</td>
</tr>
<tr id="function-showError">
<td><a href="#" class="permalink">showError</a></td>
<td>This function allows adding/removing a row to the thead, to display any errors (<span class="version">v2.15</span>; <span class="version updated">v2.23.1</span>).
<div class="collapsible">
<p>This function is ONLY included within the <code>widget-pager.js</code> and <code>jquery.tablesorter.pager.js</code> files; in version 3+, I plan to add it as a selectable option in a build.</p>
<p>In <span class="version updated">v2.23.1</span>, a <code>settings</code> parameter was included to make it match the parametered returned by the jQuery <a class="external" href="http://api.jquery.com/ajaxError/"><code>.ajaxError()</code> method</a>.</p>
<p>In <span class="version updated">v2.23.0</span>, this function will accept <code>xhr</code> and <code>exception</code> parameters provided by ajax error messages. To maintain backward compatibility, if <code>xhr</code> is a string, it will be treated as previous <code>message</code> parameter and displayed in the error row without modification.</p>
Use it as follows:
<pre class="prettyprint lang-js">$.tablesorter.showError( table, xhr, settings, exception );</pre>
<ul>
<li><code>table</code> - table DOM element (or jQuery object) of the table.</li>
<li><code>xhr</code> - a plain string, string of an HTML row, or the XMLHttpRequest (XHR) object from ajax error message.</li>
<li><code>settings</code> - a plain object containing the ajax settings, as returned by the ajaxError method.</li>
<li><code>exception</code> - exception string passed from the ajax error message.</li>
</ul>
This function will add a table row to the thead, with a class name from either the pager plugin <code>cssErrorRow</code> option setting, or the pager widget <code>pager_css.errorRow</code> option (the default class name is <code>"tablesorter-errorRow"</code>; and styled within each theme css file).
<p>When passing this function a message string (in the <code>xhr</code> parameter), there are three possibilities:</p>
<ol>
<li>Plain string (with inline HTML is okay) - <code>"<strong>table refuses to cooperate</strong>"</code></li>
<li>HTML row string - <code>'<tr><td colspan="' + table.config.columns + '">yeah, instead of showing your data... I am taking a nap</td></tr>'</code> (the <a href="#variable-columns"><code>table.config.columns</code> variable</a> contains the number of table columns; use as needed)</li>
<li>undefined - completely leave out a message parameter <code>$.tablesorter.showError( table );</code> to remove all error rows from the table thead.</li>
</ol>
As of <span class="version updated">v2.23.0</span>,
<ul>
<li><span class="label label-warning">*WARNING*</span> the <code>table</code> parameter no longer accepts multiple tables.</li>
<li>If the <code>xhr</code> parameter is not a string, then the pager <a href="#pager-ajaxerror"><code>ajaxError</code></a> callback is called to allow modification of the displayed message.</li>
</ul>
</div>
</td>
</tr>
</tbody>
<!-- non-sorting tbody -->
<tbody id="functions-widget" class="tablesorter-infoOnly">
<tr><th colspan="2">Widget Functions</th></tr>
</tbody>
<!-- widget functions -->
<tbody>
<tr id="function-bindsearch">
<td><a href="#" class="permalink">bindSearch</a></td>
<td>This filter widget function allows binding external search filters to the table (v2.13.3; <span class="version updated">v2.15</span>).
<div class="collapsible"><br>
Access it as follows:
<pre class="prettyprint lang-js">$.tablesorter.filter.bindSearch(table, $els, false);</pre>
<ul>
<li><code>table</code> - table DOM element (or jQuery object) of table.</li>
<li><code>$els</code> - jQuery object of all input (search) elements to bind.</li>
<li><code>false</code> - boolean flag to force a new search.</li>
</ul>
<p>The <code>table</code> element will only process one table. So if you pass in a jQuery object, only the <em>first table</em> will be bound to the elements (<code>$els</code>).</p>
The external elements (<code>$els</code>) will allow searching the table using "search" and "keyup" events (enter to start & escape to cancel the search), and uses the <a href="#widget-filter-livesearch"><code>filter_liveSearch</code></a> option, or delayed search.<br>
<br>
Include a <code>data-column="#"</code> attribute (where <code>#</code> is the column number) in the search input, to specify to which column the search should apply ~ see <a href="example-widget-filter-external-inputs.html">this demo</a> for a full example. <span class="label label-warning">Warning!</span>, if no <code>data-column</code> attribute is added to the input, the input will be ignored.<br>
<br>
In <span class="version">v2.15</span>, use a <code>data-column="all"</code> to bind an external any-match search filter; but note that adding an external any-match filter using this method will not override the filter set by the <a href="#widget-filter-external"><code>filter_external</code></a> option.<br>
<br>
The third function parameter, <code>false</code>, is optional. When set to <code>false</code> it forces the inputs to update their values (same as setting the <code>apply</code> flag when using the <a href="#function-setfilters"><code>setFilters</code></a> function), and reapplies (forces) the current search to be applied again, even if the filter values have not changed; this allows changing the data column attribute dynamically. See the <a href="example-widget-filter-external-inputs.html">filter external inputs demo</a> for an example.<br>
<br>
<span class="label label-warning">Warning!</span> If the third parameter is set to <code>true</code> the saved internal filters (<a href="#variable-filters"><code>config.$filters</code></a>) will be replaced - not recommended!
</div>
</td>
</tr>
<tr id="function-buildselect">
<td><a href="#" class="permalink">buildSelect</a></td>
<td>This filter widget function allows the updating or replacing of filter select options from an external source. (<span class="version">v2.17.5</span>):
<div class="collapsible"><br>
Access it as follows:
<pre class="prettyprint lang-js">$.tablesorter.filter.buildSelect( table, column, options, replace, onlyAvail );</pre>
<ul>
<li><code>table</code> - table DOM element (or jQuery object) of table.</li>
<li><code>column</code> - zero-based column index.</li>
<li><code>options</code> - array of options, jQuery object of option elements, or HTML string of option elements to apply to the targeted select.</li>
<li><code>replace</code> - a boolean value, which if <code>true</code> all options will be replaced; if <code>false</code> the options will be appended to the current list of options.</li>
<li><code>onlyAvail</code> - an optional boolean flag, which will be ignored if the <code>options</code> parameter is defined or is an empty string; otherwise it is the value passed to the function which finds all table column values; if <code>true</code>, only the available options will be diplayed.</li>
</ul>
Use this function as follows:<br>
<pre class="prettyprint lang-js">// replace filter select options for the first column with 1,2,3,4
$.tablesorter.filter.buildSelect( $('table'), 0, [ 1, 2, 3, 4 ], true );
// append "Aaron" and "Fred" to the second column's filter select options. These options will remain unsorted.
$.tablesorter.filter.buildSelect( $('table'), 1, $('<option>Aaron</option><option>Fred</option>'), false );</pre>
Please be aware that this function will allow you to modify the select options, but as soon as the user filters any column, all of the select options will refresh and obtain options from the table column, or from the <code>filter_selectSource</code> function.
</div>
</td>
</tr>
<tr id="function-getoptions">
<td><a href="#" class="permalink">getOptions</a></td>
<td>This filter widget function returns all the cached values of the set table column (<span class="version">v2.16.0</span>):
<div class="collapsible"><br>
This function respects the parsed data setting for the column, so it uses the <code>filter_useParsedData</code> option, <code>"filter-parsed"</code> class on the header, or the parser <code>parsed</code> flag settinng (<a href="example-parsers.html">ref</a>).
<p>Use it as follows:</p>
<pre class="prettyprint lang-js">$.tablesorter.filter.getOptions( table, column, onlyAvail );</pre>
<ul>
<li><code>table</code> - table DOM element (or jQuery object) of table.</li>
<li><code>column</code> - zero-based column index.</li>
<li><code>onlyAvail</code> - an optional boolean flag, which will be ignored if the <code>options</code> parameter is defined or is an empty string; otherwise it is the value passed to the function which finds all table column values; if <code>true</code>, only the available options will be diplayed.</li>
</ul>
Use this function as follows:<br>
<pre class="prettyprint lang-js">// external filter select
var index, len,
opts = '',
$table = $('table'),
column = 0, // first column
onlyAvail = false, // if true, available rows (visible rows after filtering) are returned
// arry is an array of all text content from a table column; duplicate entries are included!
array = $.tablesorter.filter.getOptions( $table, column, onlyAvail );
// process array; sort & remove duplicates (added v2.23.4)
arry = $.tablesorter.filter.processOptions( $table, column, array );
len = arry.length;
// build options
for ( index = 0; index < len; index++ ) {
opts += '<option value="' + array[ index ] + '">' + array[ index ] + '</option>';
}
$('select.external').html( opts );</pre>
<p>Please be aware that this function does not process the array, so the array may contain duplicates and will not be sorted.</p>
The filter <a href="#function-processoptions"><code>processOptions</code></a> function was added in <span class="version">v2.23.4</span> which performs those actions.
</div>
</td>
</tr>
<tr id="function-getoptionsource">
<td><a href="#" class="permalink">getOptionSource</a></td>
<td>This filter widget function returns all the cached values of the set table column (<span class="version">v2.16.0</span>):
<div class="collapsible"><br>
This function returns both the text and the parsed text for a column. So it <strong>ignores</strong> the <code>filter_useParsedData</code> option, <code>"filter-parsed"</code> class on the header, and the parser <code>parsed</code> flag settinng (<a href="example-parsers.html">ref</a>).
<p>Use it as follows:</p>
<pre class="prettyprint lang-js">$.tablesorter.filter.getOptionSource( table, column, onlyAvail );</pre>
<ul>
<li><code>table</code> - table DOM element (or jQuery object) of table.</li>
<li><code>column</code> - zero-based column index.</li>
<li><code>onlyAvail</code> - an optional boolean flag, which will be ignored if the <code>options</code> parameter is defined or is an empty string; otherwise it is the value passed to the function which finds all table column values; if <code>true</code>, only the available options will be diplayed.</li>
</ul>
Use this function as follows:<br>
<pre class="prettyprint lang-js">// external filter select
var index, len,
opts = '',
$table = $('table'),
column = 0, // first column
onlyAvail = false, // if true, available rows (visible rows after filtering) are returned
// arry is an array of objects [{ text: "Foo", parsed: "foo" }, ...] with duplicates entries removed
arry = $.tablesorter.filter.getOptionSource( $table, column, onlyAvail );
// build options
for ( index = 0; index < len; index++ ) {
opts += '<option value="' + array[ index ].parsed + '">' + array[ index ].text + '</option>';
}
$('select.external').html( opts );</pre>
<p>Please be aware that this function is different from the <a href="#function-getoptions"><code>getOptions</code></a> filter function in that an object is returned.</p>
</div>
</td>
</tr>
<tr id="function-processoptions">
<td><a href="#" class="permalink">processOptions</a></td>
<td>This filter widget function returns an array of sorted column data will duplicates removed (<span class="version">v2.23.4</span>).
<div class="collapsible"><br>
Use it as follows:
<pre class="prettyprint lang-js">$.tablesorter.filter.processOptions( table, column, array );</pre>
<ul>
<li><code>table</code> - table DOM element (or jQuery object) of table.</li>
<li><code>column</code> - zero-based column index (optional).</li>
<li><code>array</code> - An array of items to process.</li>
</ul>
The <code>column</code> parameter is optional, but if included it is used:
<ul>
<li>To check the column header for a <code>filter-select-nosort</code> class name to prevent the sorting of options.</li>
<li>To check the column header for a <code>filter-select-sort-desc</code> class name to preform a descending sort of options.</li>
<li>To check tablesorter's <code>textSorter</code> option in case there are column specific sorting algorhithms set.</li>
</ul>
See the <a href="#function-getoptions"><code>getOptions</code></a> function description or the <a href="#widget-filter-selectsource"><code>filter_selectSource</code></a> option (under "An object containing column keys"; getJSON) for examples which use this function.
</div>
</td>
</tr>
<tr id="function-getfilters">
<td><a href="#" class="permalink">getFilters</a></td>
<td>This filter widget function allows getting an array of the currently applied filters (<span class="version">v2.9</span>; <span class="version updated">v2.15</span>)
<div class="collapsible"><br>
Access it as follows:
<pre class="prettyprint lang-js">$.tablesorter.getFilters(table, flag);</pre>
<ul>
<li><code>table</code> - table DOM element (or jQuery object) of table.</li>
<li><code>flag</code> - boolean flag (optional; <code>false</code> by default; filter values obtained from the cache), added <span class="version">v2.15</span>;</li>
</ul>
Use this function as follows:<br>
<pre class="prettyprint lang-js">// use $('table') or $('table.hasFilters') to make sure the table has a filter row
// only required if the stickyHeaders or scroller widget is being used (they duplicate the table)
$.tablesorter.getFilters( $('table') );</pre>
This function returns an array of filter values (e.g. <code>[ '', '', '', '', '', '2?%' ]</code>), or <del><code>false</code></del> an empty array (<span class="version">v2.27.0</span>) if the selected table does not have a filter row or any associated inputs. It will also return an additional parameter if an external input with <code>data-column="all"</code> containing the value used when matching any table column.<br>
<br>
In <span class="version updated">v2.27.0</span>, this function will always return an array.
<br>
In <span class="version updated">v2.15</span>, this function will also return values from any external filters (set either by the <a href="#filter-external"><code>filter_external</code> option</a> or using the <a href="#function-bindsearch"><code>bindSearch</code> function</a>) - with or without an internal filter row.<br>
<br>
If the second parameter is set to <code>true</code>, it forces the function to get all of the current filter values directly from the inputs. Otherwise, by default, the function returns the last search as found in this stored data <code>$('table').data('lastSearch');</code>.
</div>
</td>
</tr>
<tr id="function-setfilters">
<td><a href="#" class="permalink">setFilters</a></td>
<td>This filter widget function allows setting of the filters; include a <code>true</code> boolean to actually apply the search (<span class="version">v2.9</span>; <span class="version updated">v2.24.3</span>):
<div class="collapsible"><br>
Access it as follows:
<pre class="prettyprint lang-js">$.tablesorter.setFilters(table, filter, apply);</pre>
<ul>
<li><code>table</code> - table DOM element (or jQuery object) of table.</li>
<li><code>filter</code> - array of filter values to apply to the table.</li>
<li><code>apply</code> - boolean flag, if <code>false</code> (<del>default setting</del>; default is now <code>true</code> as of v2.24.3), the input values are updated, but the search is not applied to the table.</li>
</ul>
Use this function as follows:<br>
<pre class="prettyprint lang-js">// update filters, but don't apply the search
$.tablesorter.setFilters( $('table'), [ '', '', '', '', '', '2?%' ], false );
// update filters, AND apply the search (apply is undefined; defaults to true in v2.24.3+)
$.tablesorter.setFilters( $('table'), [ '', '', '', '', '', '2?%' ] ); // this will now use the search method</pre>
This function returns <code>true</code> if the filters were sucessfully applied, or <code>false</code> if the table does not have a filter row.<br>
<p>In <span class="version updated">v2.24.3</span>, if the <code>apply</code> parameter is left undefined, it will now default to <code>true</code>.</p>
As of <span class="version updated">v2.15</span>, this function will also set values in any external filters (set either by the <a href="#filter-external"><code>filter_external</code> option</a> or using the <a href="#function-bindsearch"><code>bindSearch</code> function</a>). An additional search parameter can be included to match any column, but please include an external input with <code>data-column="all"</code> using the <code>bindSearch</code> function so your users will know that a search has been applied.<br>
<br>
Also, changed is that when a <code>true</code> value is passed as a third parameter, the search is forced to refresh on the table; otherwise, if the filters set in the search exactly match the previous search, it would be ignored - this was added to prevent numerous ajax calls with exactly the same search or sort parameters (when using the pager).
</div>
</td>
</tr>
<tr id="function-resizablereset">
<td><a href="#" class="permalink">resizableReset</a></td>
<td>This resizable widget function allows resetting column width changes and clearing out the saved set widths (<span class="version">v2.4</span>; <span class="version updated">v2.10.1</span>)
<div class="collapsible"><br>
Use it as follows:
<pre class="prettyprint lang-js">$.tablesorter.resizableReset(table, refreshing);</pre>
<ul>
<li><code>table</code> - table DOM element (or jQuery object) of table(s).</li>
<li><code>refreshing</code> - if this flag is set to <code>true</code>, the stored resize settings will not be cleared; all other settings will clear the storage.</li>
</ul>
This function is used when the user right-clicks on the table header (the <code>refreshing</code> flag is undefined at that time to allow saving the changes).
</div>
</td>
</tr>
<tr id="function-resizeevent">
<td><a href="#" class="permalink">addHeaderResizeEvent</a></td>
<td>Added a <code>resize</code> event to the table headers - used by the stickyHeaders widget, but this is a public function available to any widget (<span class="version">v2.10</span>).
<div class="collapsible"><br>
There is no built-in resize event for non-window elements, so when this function is active it triggers a <code>resize</code> event when the header cell changes size. So, if you are writing your own widget and need a header <code>resize</code> event, just include the <code>jquery.tablesorter.widgets.js</code> file, or just the extract the function from that file.<br>
<br>
Access it as follows:
<pre class="prettyprint lang-js">$.tablesorter.addHeaderResizeEvent(table, disable, { timer : 250 });</pre>
<ul>
<li><code>table</code> - table DOM element (or jQuery object) of table.</li>
<li><code>disable</code> - boolean flag, if <code>false</code> events for the targeted table are disabled.</li>
<li><code>timer</code> - currently only the timer option is available for modification.</li>
</ul>
Enable these triggered events as follows:
<pre class="prettyprint lang-js">var table = $('table')[0],
disable = false,
options = {
timer : 250 // header cell size is checked every 250 milliseconds (1/4 of a second)
};
$.tablesorter.addHeaderResizeEvent( table, disable, options );</pre>Then use it in your custom widget as follows:
<pre class="prettyprint lang-js">$(table).on('resize', function(event, columns) {
// columns contains an array of header cells that were resized
// this seemed like a better idea than firing off a resize event for every
// column when the table adjusts itself to fit within its container
event.stopPropagation(); // optional
// do something
console.log( columns );
});</pre>To disable these resize events, use this code:<pre class="prettyprint lang-js">// Disable resize event triggering:
var table = $('table')[0];
$.tablesorter.addHeaderResizeEvent( table, true );</pre>
</div>
</td>
</tr>
<tr id="function-storage">
<td><a href="#" class="permalink">storage</a></td>
<td>This function allows saving specific table data (especially widgets) to local storage (cookie fallback for no browser support) (v2.1)
<div class="collapsible"><br>
Access it as follows:
<pre class="prettyprint lang-js">$.tablesorter.storage(table, key, value, options);</pre>
<ul>
<li><code>table</code> - table DOM element (or jQuery object) of table.</li>
<li><code>key</code> - name of the variable to save</li>
<li><code>value</code> - value of the variable that is saved (for saving only); set as <code>undefined</code> if wanting to get a value with options.</li>
<li><code>options</code> - storage options; see below</li>
</ul>
This function attempts to give every table a unique identifier using both the page url and table id (or index on the page if no id exists), by default. Here is a usage example and a look at what is stored within the local storage:
<pre class="prettyprint lang-js">$.tablesorter.storage( $('#tablesorter-demo')[0], 'test', '123');
// stored under the "test" value as {"/tablesorter/docs/":{"tablesorter-demo":"123"}}
</pre>
The saved table url & id can be overridden by setting table data attributes <code>data-table-page</code> (url) and <code>data-table-group</code> (id), as in this sample markup:
<pre class="prettyprint lang-html"><table class="tablesorter" data-table-page="mydomain" data-table-group="financial">...</table>)</pre>
To change the default data attributes, use the <code>options</code> to modify them as follows:<pre class="prettyprint lang-js">$.tablesorter.storage( table, key, value, {
// table id/group id
id: 'group1',
// this group option sets name of the table attribute with the ID;
// but the value within this data attribute is overridden by the above id option
group: 'data-table-group',
// table pages
url: 'page1',
// this page option sets name of the table attribute with the page/url;
// but the value within the data attribute is overridden by the above url option
page: 'data-table-page',
// Option added v2.28.8; use the first letter of (l)ocal, (s)ession or (c)ookie
// to set the desired storage type. Any setting of this option will override
// any setting in the `useSessionStorage` option.
storageType: 'l', // local
// DEPRECATED in v2.28.8; use the `storageType` option.
// Option added v2.21.3; if `true` the storage function will use sessionStorage
// if not defined, the `config.widgetOptions.storage_useSessionStorage` setting is checked
// if no settings are found, it will default to `false`, and use localStorage
// useSessionStorage: false
});</pre>
The priority of table ID settings is as follows:
<ol>
<li><code>options.id</code> setting</li>
<li>Table data attribute (<code>"data-table-group"</code> by default) value</li>
<li><a href="#widget-storage-table-id"><code>widgetOptions.storage_tableId</code></a> option</li>
<li>Table id attribute</li>
<li>Index of the table (compared to other tables with a "tablesorter" class name) on the page</li>
</ol>
The priority of table url (group) settings is as follows:
<ol>
<li><code>options.url</code> setting</li>
<li>Table data attribute (<code>"data-table-page"</code> by default) value</li>
<li><a href="#widget-storage-fixed-url"><code>widgetOptions.storage_fixedUrl</code></a> option value</li>
<li><a href="#fixedurl" class="alert" title="deprecated"><code>config.fixedUrl</code></a> option value</li>
<li><code>window.location.pathname</code></li>
</ol>
<br>
The <a href="#widget-storage-fixed-url"><code>storage_fixedUrl</code></a> widget option allows you to override the current page url (it doesn't need to be a url, just some constant value) and save data for multiple tables across a domain. The value from this option has a lower priority than the <code>options</code> id or group settings (see priority list above).<br>
<br>
When using the storage utility to <em>get</em> a value <em>and</em> use custom table options, set the <code>value</code> parameter as <code>undefined</code>.<br>
<br>
Lastly, this storage utility function needs the <code>parseJSON</code> function available in jQuery v1.4.1+.
</div>
</td>
</tr>
</tbody>
</table>
<a id="Download"></a>
<h1>Download</h1>
<strong>File Downloads</strong>
<ul>
<li>
Get all files (plugin, documentation, add-ons, themes):
<a class="btn btn-primary" href="https://github.com/Mottie/tablesorter/archive/master.zip">zip</a>
or
<a class="btn btn-primary" href="https://github.com/Mottie/tablesorter/archive/master.tar.gz">tar.gz</a>
</li>
<li>Download a <a href="https://github.com/Mottie/tablesorter/releases">previous release</a>.</li>
<li>Install with <a class="external" href="http://bower.io/">bower</a>: <code>bower install jquery.tablesorter</code></li>
<li>Install with <a class="external" href="http://nodejs.org/">node.js</a>: <code>npm install tablesorter</code></li>
<li>Use CDN: <a class="external" href="https://cdnjs.com/libraries/jquery.tablesorter">jquery.tablesorter</a></li>
</ul>
<strong id="Download-Required">Required:</strong>
<ul>
<li><a class="external" href="http://jquery.com/download/">jQuery</a> (1.2.6 or higher; some widgets, demos & <a class="external" href="http://api.jquery.com/data/#data-html5">HTML5 data-attributes</a> need jQuery 1.4.3+)</li>
<li><a href="../dist/js/jquery.tablesorter.min.js">jquery.tablesorter.min.js</a> (minified for production - please put the file on your server)</li>
</ul>
<strong id="Download-Addons">Optional / Add-Ons:</strong>
<ul>
<li><a class="external" href="https://github.com/jquery-orphans/jquery-metadata">jQuery Metadata 2.1</a> (required for setting <a href="#metadata">inline options</a>)</li>
<li><a href="../js/jquery.tablesorter.js">jquery.tablesorter.js</a></li>
<li><a href="../addons/pager/jquery.tablesorter.pager.js">jquery.tablesorter.pager.js</a> (<a href="example-pager.html">demo</a>)</li>
<li><a href="../js/jquery.tablesorter.widgets.js">jquery.tablesorter.widgets.js</a> (includes the jQuery UI theme, columns styling, resizable columns, filter, sticky header and save sort widgets).</li>
</ul>
<strong id="Download-Themes">Themes:</strong>
<p>Theme zip files have been removed. There are now numerous themes available which <a href="themes.html">can be seen here</a>.</p>
<a id="Compatibility"></a>
<h1>Browser Compatibility</h1>
<p>tablesorter has been tested successfully in the following browsers with Javascript enabled:</p>
<ul>
<li>Firefox 2+</li>
<li>Internet Explorer 6+</li>
<li>Safari 2+</li>
<li>Opera 9+</li>
<li>Konqueror</li>
</ul>
<p><a class="external" href="http://jquery.com/browser-support/">jQuery Browser Compatibility</a></p>
<a id="Support"></a>
<h1>Support</h1>
<p>First, please review the <a class="external" href="https://github.com/Mottie/tablesorter/wiki/FAQ">FAQ</a> page to see if it will help you resolve the problem.</p>
<p>If you are having a problem with the plugin or you want to submit a feature request, please <a class="external" href="https://github.com/Mottie/tablesorter/issues">submit an issue</a>.</p>
<p>Support is also available from <a class="external" href="http://stackoverflow.com/questions/tagged/tablesorter">stackoverflow</a>.</p>
<p>If you would like to contribute, <a class="external" href="https://github.com/Mottie/tablesorter">fork a copy on github</a>.</p>
<p>Some basic <a href="../test.html">unit testing</a> has been added (v2.6). If you would like to add more or report a problem, please use the appropriate link above.</p>
<p>For questions about jQuery, try <a class="external" href="http://irc.jquery.org/">irc</a>, <a class="external" href="http://stackoverflow.com/tags/jquery/info">stackoverflow</a>, or the <a class="external" href="http://forum.jquery.com/">jQuery forums</a>.</p>
<a id="Credits"></a>
<h1>Credits</h1>
<p>Written by Christian Bach.</p>
<p>
Documentation written by <a class="external" href="http://www.ghidinelli.com">Brian Ghidinelli</a>,
based on <a class="external" href="http://malsup.com/jquery/">Mike Alsup's</a> great documention.
</p>
<p>
Additional & Missing documentation, alphanumeric sort, numerous widgets, unit testing and other changes added by <a class="external" href="https://github.com/Mottie/tablesorter">Mottie</a>.
</p>
<p>
Thanks to all that have contributed code, comments, feedback and everything else. A special thanks goes out to:
</p>
<ul>
<li><a href="https://github.com/thezoggy">thezoggy</a></li>
<li><a href="https://github.com/TheSin-">TheSin-</a></li>
<li><a href="https://github.com/NickCraver">NickCraver</a></li>
<li><a href="https://github.com/themilkman">themilkman</a> (maintains <a href="https://github.com/themilkman/jquery-tablesorter-rails">jquery-tablesorter-rails</a>)</li>
<li><a href="https://github.com/VorontsovIE">VorontsovIE</a></li>
<li>and <a href="https://github.com/Mottie/tablesorter/graphs/contributors">all the contributors</a>!</li>
</ul>
<p></p>
<a class="external" href="http://ejohn.org">John Resig</a> for the fantastic <a class="external" href="http://jquery.com">jQuery</a>
</div>
<!-- jQuery -->
<script src="js/jquery-latest.min.js"></script>
<script async src="js/jquery-migrate-3.1.0.min.js"></script>
<script async src="js/jquery-ui.min.js"></script>
<script async src="js/prettify.js"></script>
<script async src="js/docs.js"></script>
<script async src="js/search.js"></script>
<!--[if lte IE 8]>
<script src="js/search-ie.js"></script>
<![endif]-->
<!-- Tablesorter: required -->
<script src="../js/jquery.tablesorter.combined.js"></script>
<script async>
$.extend( $.tablesorter.defaults, {
theme: 'blue',
widthFixed: true
});
$('#tablesorter-demo').tablesorter({widgets:['zebra']});
setTimeout(function(){
$('.compatibility').tablesorter();
$('table.options, table.api').tablesorter({widgets:['stickyHeaders']});
}, 1000);
</script>
</body>
</html>
|