Code Sample<\/h3>\n\r\n\r\n<table class="responsive-table">\r\n<thead>\r\n<tr>\r\n<th scope="col">Column 1<\/th>\r\n<th scope="col">Column 2<\/th>\r\n<th scope="col">Column 3<\/th>\r\n<th scope="col">Column 4<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr>\r\n<td>Data 1,1<\/td>\r\n<td>Data 2,1<\/td>\r\n<td>Data 3,1<\/td>\r\n<td>Data 4,1<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>Data 1,2<\/td>\r\n<td>Data 2,2<\/td>\r\n<td>Data 3,2<\/td>\r\n<td>Data 4,2<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>Data 1,3<\/td>\r\n<td>Data 2,3<\/td>\r\n<td>Data 3,3<\/td>\r\n<td>Data 4,3<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n\r\n<\/pre>\nSortable Tables<\/h2>\n
Using the class sortable<\/strong> you can create a table where the visitor can sort by any of the columns. In the column headings you can use the class name sort-default<\/strong> to choose which column the table will be sorted on after page load. If you don’t set a default, the table will be sorted by the first column.<\/p>\nYou can also add the class name desc<\/strong> to reverse the order of the initial sort column.<\/p>\nIf you set data-column-type<\/strong> to date<\/strong> the script will attempt to parse the column’s contents as dates. (If the column’s contents aren’t valid dates, it’ll default back to strings.)<\/p>\nYou cannot use both the sortable<\/strong> and responsive-table<\/strong> classes at the same time.<\/em><\/p>\n\n\n\n| Rank<\/th>\n | Sales (Millions)<\/th>\n | Album<\/th>\n | Artist<\/th>\n | Year<\/th>\n<\/tr>\n<\/thead>\n |
\n\n| 1<\/td>\n | 47<\/td>\n | Thriller<\/td>\n | Michael Jackson<\/td>\n | 1982<\/td>\n<\/tr>\n |
\n| 2<\/td>\n | 41<\/td>\n | Their Greatest Hits 1971-1975<\/td>\n | The Eagles<\/td>\n | 1976<\/td>\n<\/tr>\n |
\n| 3<\/td>\n | 32<\/td>\n | Hotel California<\/td>\n | The Eagles<\/td>\n | 1976<\/td>\n<\/tr>\n |
\n| 4<\/td>\n | 29<\/td>\n | Come on Over<\/td>\n | Shania Twain<\/td>\n | 1997<\/td>\n<\/tr>\n |
\n| 5<\/td>\n | 29<\/td>\n | Led Zeppelin IV<\/td>\n | Led Zeppelin<\/td>\n | 1971<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n You can also use data-column-type=”weekday”<\/strong> to sort by weekday.<\/p>\n\n\n\n| Weekday<\/th>\n | Menu<\/th>\n<\/tr>\n<\/thead>\n | \n\n| Monday<\/td>\n | Meatloaf<\/td>\n<\/tr>\n | \n| Tuesday<\/td>\n | Chicken Pot Pie<\/td>\n<\/tr>\n | \n| Wednesday<\/td>\n | Macaroni & Cheese<\/td>\n<\/tr>\n | \n| Thursday<\/td>\n | Pork Chops<\/td>\n<\/tr>\n | \n| Friday<\/td>\n | Pizza<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\nCode Samples<\/h3>\n\r\n<table class="sortable">\r\n\t<thead>\r\n\t\t<tr>\r\n\t\t\t<th class="sort-default">Rank<\/th>\r\n\t\t\t<th>Sales (Millions)<\/th>\r\n\t\t\t<th>Album<\/th>\r\n\t\t\t<th>Artist<\/th>\r\n\t\t\t<th data-column-type="date">Year<\/th>\r\n\t\t<\/tr>\r\n\t<\/thead>\r\n\t<tbody>\r\n\t\t<tr>\r\n\t\t\t<td>1<\/td>\r\n\t\t\t<td>47<\/td>\r\n\t\t\t<td>Thriller<\/td>\r\n\t\t\t<td>Michael Jackson<\/td>\r\n\t\t\t<td>1982<\/td>\r\n\t\t<\/tr>\r\n\t\t<tr>\r\n\t\t\t<td>2<\/td>\r\n\t\t\t<td>41<\/td>\r\n\t\t\t<td>Their Greatest Hits 1971-1975<\/td>\r\n\t\t\t<td>The Eagles<\/td>\r\n\t\t\t<td>1976<\/td>\r\n\t\t<\/tr>\r\n\t\t<tr>\r\n\t\t\t<td>3<\/td>\r\n\t\t\t<td>32<\/td>\r\n\t\t\t<td>Hotel California<\/td>\r\n\t\t\t<td>The Eagles<\/td>\r\n\t\t\t<td>1976<\/td>\r\n\t\t<\/tr>\r\n\t\t<tr>\r\n\t\t\t<td>4<\/td>\r\n\t\t\t<td>29<\/td>\r\n\t\t\t<td>Come on Over<\/td>\r\n\t\t\t<td>Shania Twain<\/td>\r\n\t\t\t<td>1997<\/td>\r\n\t\t<\/tr>\r\n\t\t<tr>\r\n\t\t\t<td>5<\/td>\r\n\t\t\t<td>29<\/td>\r\n\t\t\t<td>Led Zeppelin IV<\/td>\r\n\t\t\t<td>Led Zeppelin<\/td>\r\n\t\t\t<td>1971<\/td>\r\n\t\t<\/tr>\r\n\t<\/tbody>\r\n<\/table>\r\n<\/pre>\n <\/p>\n <table class="sortable">\r\n <thead>\r\n <tr>\r\n <th data-column-type="weekday">Weekday<\/th>\r\n <th>Menu<\/th>\r\n <\/tr>\r\n <\/thead>\r\n <tbody>\r\n <tr>\r\n <td>Monday<\/td>\r\n <td>Meatloaf<\/td>\r\n <\/tr>\r\n <tr>\r\n <td>Tuesday<\/td>\r\n <td>Chicken Pot Pie<\/td>\r\n <\/tr>\r\n <tr>\r\n <td>Wednesday<\/td>\r\n <td>Macaroni &amp; Cheese<\/td>\r\n <\/tr>\r\n <tr>\r\n <td>Thursday<\/td>\r\n <td>Pork Chops<\/td>\r\n <\/tr>\r\n <tr>\r\n <td>Friday<\/td>\r\n <td>Pizza<\/td>\r\n <\/tr>\r\n <\/tbody>\r\n<\/table><\/pre>\n","protected":false},"excerpt":{"rendered":"The table tag is intended to hold tabulated data. Unlike a list or a paragraph, data in a table is given additional meaning by its placement within the row\/column structure. Never use a table to control page design layout. If you want to arrange items in rows and columns, see Rows and Columns. Tables are […]<\/p>\n","protected":false},"author":411,"featured_media":3785,"parent":3510,"menu_order":4,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"footnotes":""},"class_list":["post-3519","page","type-page","status-publish","has-post-thumbnail","hentry"],"_links":{"self":[{"href":"https:\/\/www.montclair.edu\/university-communications\/wp-json\/wp\/v2\/pages\/3519","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.montclair.edu\/university-communications\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.montclair.edu\/university-communications\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.montclair.edu\/university-communications\/wp-json\/wp\/v2\/users\/411"}],"replies":[{"embeddable":true,"href":"https:\/\/www.montclair.edu\/university-communications\/wp-json\/wp\/v2\/comments?post=3519"}],"version-history":[{"count":2,"href":"https:\/\/www.montclair.edu\/university-communications\/wp-json\/wp\/v2\/pages\/3519\/revisions"}],"predecessor-version":[{"id":3735,"href":"https:\/\/www.montclair.edu\/university-communications\/wp-json\/wp\/v2\/pages\/3519\/revisions\/3735"}],"up":[{"embeddable":true,"href":"https:\/\/www.montclair.edu\/university-communications\/wp-json\/wp\/v2\/pages\/3510"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.montclair.edu\/university-communications\/wp-json\/wp\/v2\/media\/3785"}],"wp:attachment":[{"href":"https:\/\/www.montclair.edu\/university-communications\/wp-json\/wp\/v2\/media?parent=3519"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}} | |