Blame
|
1 | # DataTable |
||||||
| 2 | ||||||||
| 3 | [DataTable Documentation](/-/help/plugins#datatable) |
|||||||
| 4 | ||||||||
| 5 | ## Example: Animals |
|||||||
| 6 | ||||||||
| 7 | A datatable with default settings. |
|||||||
| 8 | ||||||||
| 9 | {{datatable |
|||||||
| 10 | | Animal | Habitat | Diet | Lifespan | Fun Fact | |
|||||||
| 11 | | ------- | ------------------ | ------------------- | --------- | ----------------------------------------------- | |
|||||||
| 12 | | Otter | Rivers, lakes | Fish, crustaceans | 10-25 yrs | Known for sliding on their bellies! | |
|||||||
| 13 | | Eagle | Mountains, forests | Small mammals, fish | 20-30 yrs | Sharpest eyesight of all birds. | |
|||||||
| 14 | | Dolphin | Oceans | Fish, squid | 40-50 yrs | Sleep with one eye open (unihemispheric sleep). | |
|||||||
| 15 | | Sloth | Rainforests | Leaves, fruits | 12-20 yrs | Move slower than a growing grass! | |
|||||||
| 16 | | Penguin | Antarctica | Fish, krill | 20-30 yrs | Can’t fly but are excellent swimmers. | |
|||||||
| 17 | }} |
|||||||
| 18 | ||||||||
| 19 | ## Example: Months |
|||||||
| 20 | ||||||||
| 21 | A datatable with caption, not searchable, with fixed height. |
|||||||
| 22 | ||||||||
| 23 | ``` |
|||||||
| 24 | {{datatable |
|||||||
| 25 | |searchable=false |
|||||||
| 26 | |caption=Months |
|||||||
| 27 | |perpage=5 |
|||||||
| 28 | |fixedheight=true |
|||||||
| 29 | ||||||||
| 30 | | No | Month | Length | |
|||||||
| 31 | | --:| --------- | ------:| |
|||||||
| 32 | | 1 | January | 31 | |
|||||||
| 33 | | 2 | Feburary | 28 | |
|||||||
| 34 | | 3 | March | 31 | |
|||||||
| 35 | | 4 | April | 30 | |
|||||||
| 36 | | 5 | May | 31 | |
|||||||
| 37 | | 6 | June | 30 | |
|||||||
| 38 | | 7 | July | 31 | |
|||||||
| 39 | | 8 | August | 31 | |
|||||||
| 40 | | 9 | September | 30 | |
|||||||
| 41 | | 10 | October | 31 | |
|||||||
| 42 | | 11 | November | 30 | |
|||||||
| 43 | | 12 | December | 31 | |
|||||||
| 44 | }} |
|||||||
| 45 | ``` |
|||||||
| 46 | ||||||||
| 47 | {{datatable |
|||||||
| 48 | |searchable=false |
|||||||
| 49 | |caption=Months |
|||||||
| 50 | |perpage=5 |
|||||||
| 51 | |fixedheight=true |
|||||||
| 52 | ||||||||
| 53 | | No | Month | Length | |
|||||||
| 54 | | --:| --------- | ------:| |
|||||||
| 55 | | 1 | January | 31 | |
|||||||
| 56 | | 2 | Feburary | 28 | |
|||||||
| 57 | | 3 | March | 31 | |
|||||||
| 58 | | 4 | April | 30 | |
|||||||
| 59 | | 5 | May | 31 | |
|||||||
| 60 | | 6 | June | 30 | |
|||||||
| 61 | | 7 | July | 31 | |
|||||||
| 62 | | 8 | August | 31 | |
|||||||
| 63 | | 9 | September | 30 | |
|||||||
| 64 | | 10 | October | 31 | |
|||||||
| 65 | | 11 | November | 30 | |
|||||||
| 66 | | 12 | December | 31 | |
|||||||
| 67 | }} |
|||||||
|
68 | |||||||
| 69 | ## Example: from a CSV attachment |
|||||||
| 70 | ||||||||
| 71 | A `src` pointing at a CSV attachment renders it as a datatable. This page has |
|||||||
| 72 | `otters.csv` attached (delimiter `;`, with a header row, both defaults). |
|||||||
| 73 | ||||||||
| 74 | ``` |
|||||||
| 75 | {{datatable |
|||||||
| 76 | |src=otters.csv |
|||||||
| 77 | |caption=Otters |
|||||||
| 78 | }} |
|||||||
| 79 | ``` |
|||||||
| 80 | ||||||||
| 81 | {{datatable |
|||||||
| 82 | |src=otters.csv |
|||||||
| 83 | |caption=Otters |
|||||||
| 84 | }} |
|||||||
| 85 | ||||||||
| 86 | ## Example: selecting columns with `column0` |
|||||||
| 87 | ||||||||
| 88 | `column0` picks which columns to show using 0-based indices, so `0,2` keeps the |
|||||||
| 89 | first and third columns (*Species* and *Habitat*). It is the same as `columns`, |
|||||||
| 90 | which counts from 1 instead. An absolute `src` reads the CSV from another page; |
|||||||
| 91 | here it points back at this page's own attachment. |
|||||||
| 92 | ||||||||
| 93 | ``` |
|||||||
| 94 | {{datatable |
|||||||
| 95 | |src=/Examples/DataTable/otters.csv |
|||||||
| 96 | |column0=0,2 |
|||||||
| 97 | |caption=Species and habitat |
|||||||
| 98 | }} |
|||||||
| 99 | ``` |
|||||||
| 100 | ||||||||
| 101 | {{datatable |
|||||||
| 102 | |src=/Examples/DataTable/otters.csv |
|||||||
| 103 | |column0=0,2 |
|||||||
| 104 | |caption=Species and habitat |
|||||||
| 105 | }} |
|||||||
