窗格垂直堆疊於資料表旁
此範例展示如何將窗格顯示於資料表的左側,而非上方。
姓名 | 職稱 | 辦公室 | 年齡 | 開始日期 | 薪資 |
---|---|---|---|---|---|
姓名 | 職稱 | 辦公室 | 年齡 | 開始日期 | 薪資 |
Tiger Nixon | 系統架構師 | 愛丁堡 | 61 | 2011/04/25 | $3,120 |
Garrett Winters | 總監 | 愛丁堡 | 63 | 2011/07/25 | $5,300 |
Ashton Cox | 技術作者 | 舊金山 | 66 | 2009/01/12 | $4,800 |
Cedric Kelly | JavaScript 開發人員 | 愛丁堡 | 22 | 2012/03/29 | $3,600 |
Jenna Elliott | 財務主管 | 愛丁堡 | 33 | 2008/11/28 | $5,300 |
Brielle Williamson | 整合專家 | 紐約 | 61 | 2012/12/02 | $4,525 |
Herrod Chandler | 銷售助理 | 舊金山 | 59 | 2012/08/06 | $4,080 |
Rhona Davidson | 整合專家 | 愛丁堡 | 55 | 2010/10/14 | $6,730 |
Colleen Hurst | JavaScript 開發人員 | 舊金山 | 39 | 2009/09/15 | $5,000 |
Sonya Frost | 軟體工程師 | 愛丁堡 | 23 | 2008/12/13 | $3,600 |
Jena Gaines | 系統架構師 | 倫敦 | 30 | 2008/12/19 | $5,000 |
Quinn Flynn | 財務主管 | 愛丁堡 | 22 | 2013/03/03 | $4,200 |
Charde Marshall | 區域總監 | 舊金山 | 36 | 2008/10/16 | $5,300 |
Haley Kennedy | 資深行銷設計師 | 倫敦 | 43 | 2012/12/18 | $4,800 |
Tatyana Fitzpatrick | 區域總監 | 倫敦 | 19 | 2010/03/17 | $2,875 |
Michael Silva | 資深行銷設計師 | 倫敦 | 66 | 2012/11/27 | $3,750 |
Paul Byrd | JavaScript 開發人員 | 紐約 | 64 | 2010/06/09 | $5,000 |
Gloria Little | 系統管理員 | 紐約 | 59 | 2009/04/10 | $3,120 |
Bradley Greer | 軟體工程師 | 倫敦 | 41 | 2012/10/13 | $3,120 |
Dai Rios | 系統架構師 | 愛丁堡 | 35 | 2012/09/26 | $4,200 |
Jenette Caldwell | 財務主管 | 紐約 | 30 | 2011/09/03 | $4,965 |
Yuri Berry | 系統架構師 | 紐約 | 40 | 2009/06/25 | $3,600 |
Caesar Vance | 技術作者 | 紐約 | 21 | 2011/12/12 | $4,965 |
Doris Wilder | 銷售助理 | 愛丁堡 | 23 | 2010/09/20 | $4,965 |
Angelica Ramos | 系統架構師 | 倫敦 | 36 | 2009/10/09 | $2,875 |
Gavin Joyce | 開發人員 | 愛丁堡 | 42 | 2010/12/22 | $4,525 |
Jennifer Chang | 區域總監 | 倫敦 | 28 | 2010/11/14 | $4,080 |
Brenden Wagner | 軟體工程師 | 舊金山 | 18 | 2011/06/07 | $3,750 |
Ebony Grimes | 軟體工程師 | 舊金山 | 48 | 2010/03/11 | $2,875 |
Russell Chavez | 總監 | 愛丁堡 | 20 | 2011/08/14 | $3,600 |
Michelle House | 整合專家 | 愛丁堡 | 37 | 2011/06/02 | $3,750 |
Suki Burks | 開發人員 | 倫敦 | 53 | 2009/10/22 | $2,875 |
Prescott Bartlett | 技術作者 | 倫敦 | 27 | 2011/05/07 | $6,730 |
Gavin Cortez | 技術作者 | 舊金山 | 22 | 2008/10/26 | $6,730 |
Martena Mccray | 整合專家 | 愛丁堡 | 46 | 2011/03/09 | $4,080 |
Unity Butler | 資深行銷設計師 | 舊金山 | 47 | 2009/12/09 | $3,750 |
Howard Hatfield | 財務主管 | 舊金山 | 51 | 2008/12/16 | $4,080 |
Hope Fuentes | 財務主管 | 舊金山 | 41 | 2010/02/12 | $4,200 |
Vivian Harrell | 系統架構師 | 舊金山 | 62 | 2009/02/14 | $4,965 |
Timothy Mooney | 財務主管 | 倫敦 | 37 | 2008/12/11 | $4,200 |
Jackson Bradshaw | 總監 | 紐約 | 65 | 2008/09/26 | $5,000 |
Miriam Weiss | 支援工程師 | 愛丁堡 | 64 | 2011/02/03 | $4,965 |
Bruno Nash | 軟體工程師 | 倫敦 | 38 | 2011/05/03 | $4,200 |
Odessa Jackson | 支援工程師 | 愛丁堡 | 37 | 2009/08/19 | $3,600 |
Thor Walton | 開發人員 | 紐約 | 61 | 2013/08/11 | $3,600 |
Finn Camacho | 支援工程師 | 舊金山 | 47 | 2009/07/07 | $4,800 |
Elton Baldwin | 資料協調員 | 愛丁堡 | 64 | 2012/04/09 | $6,730 |
Zenaida Frank | 軟體工程師 | 紐約 | 63 | 2010/01/04 | $4,800 |
Zorita Serrano | 軟體工程師 | 舊金山 | 56 | 2012/06/01 | $5,300 |
Jennifer Acosta | JavaScript 開發人員 | 愛丁堡 | 43 | 2013/02/01 | $2,875 |
Cara Stevens | 銷售助理 | 紐約 | 46 | 2011/12/06 | $4,800 |
Hermione Butler | 總監 | 倫敦 | 47 | 2011/03/21 | $4,080 |
Lael Greer | 系統管理員 | 倫敦 | 21 | 2009/02/27 | $3,120 |
Jonas Alexander | 開發人員 | 舊金山 | 30 | 2010/07/14 | $5,300 |
Shad Decker | 區域總監 | 愛丁堡 | 51 | 2008/11/13 | $5,300 |
Michael Bruce | JavaScript 開發人員 | 愛丁堡 | 29 | 2011/06/27 | $4,080 |
Donna Snider | 系統架構師 | 紐約 | 27 | 2011/01/25 | $3,120 |
- JavaScript
- HTML
- CSS
- Ajax
- 伺服器端腳本
- 註解
下方顯示的 JavaScript 用於初始化此範例中顯示的表格
var table = $('#example').DataTable({ searchPanes: { layout: 'columns-1' }, pageLength: 25 }); $('div.dtsp-verticalPanes').append(table.searchPanes.container());
let table = new DataTable('#example', { searchPanes: { layout: 'columns-1' }, pageLength: 25 }); document .querySelector('div.dtsp-verticalPanes') .appendChild(table.searchPanes.container().get(0));
除了上述程式碼,還載入了下列 JavaScript 程式庫檔案供本範例使用
下方顯示的 HTML 是原始 HTML 表格元素,尚未經 DataTables 增強
此範例除了從程式庫檔案載入的 CSS (如下) 外,還使用了一些額外的 CSS,以正確顯示表格。使用的額外 CSS 如下所示
div.dtsp-verticalContainer{ display: flex; flex-direction: row; flex-wrap: wrap; justify-content: flex-start; align-content: flex-start; align-items: flex-start; } div.dtsp-verticalContainer div.dtsp-verticalPanes, div.dtsp-verticalContainer div.container{ width: 30%; flex-grow: 0; flex-shrink: 0; flex-basis: 0; } div.dtsp-verticalContainer div.dtsp-verticalPanes{ flex-grow: 1; flex-shrink: 0; flex-basis: 26%; } div.dtsp-verticalPanes { margin-right: 20px; } div.dtsp-title { margin-right: 0px !important; margin-top: 13px !important; } input.dtsp-search { min-width: 0px !important; padding-left: 0px !important; margin: 0px !important; } div.dtsp-verticalContainer div.dtsp-verticalPanes div.dtsp-searchPanes{ flex-direction: column; flex-basis: 0px; } div.dtsp-verticalContainer div.dtsp-verticalPanes div.dtsp-searchPanes div.dtsp-searchPane{ flex-basis: 0px; } div.dtsp-verticalContainer div.container{ flex-grow: 1; flex-shrink: 0; flex-basis: 60%; } div.dtsp-panesContainer { border: 1px solid #ccc; border-radius: 6px; padding: 1em !important; } div.dtsp-titleRow { display: flex; flex-direction: column; gap: 5px; } div.dtsp-titleRow div.dtsp-title { margin-top: 0 !important; padding-top: 0; } html.dark div.dtsp-panesContainer { border: 1px solid rgba(255, 255, 255, 0.2); }
載入下列 CSS 程式庫檔案供此範例使用,以提供表格的樣式
此表格透過 Ajax 載入資料。下方顯示已載入的最新資料。當載入任何額外資料時,此資料將自動更新。
下方顯示用於執行此表格伺服器端處理的腳本。請注意,這只是一個使用 PHP 的範例腳本。伺服器端處理腳本可以使用任何語言編寫,使用 DataTables 文件中描述的協定。