瀏覽代碼

Example for #629

Maurits van der Schee 4 年之前
父節點
當前提交
5844c74b55
共有 1 個文件被更改,包括 45 次插入0 次删除
  1. 45
    0
      examples/clients/datatables.html

+ 45
- 0
examples/clients/datatables.html 查看文件

@@ -0,0 +1,45 @@
1
+<html>
2
+<head>
3
+<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css"/>
4
+<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js"></script>
5
+<script type="text/javascript" src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
6
+<script>
7
+$(document).ready(function() {
8
+    $('#example').DataTable( {
9
+        ajax: {
10
+            url: '/api.php/records/posts?join=categories&join=users',
11
+            dataSrc: 'records'
12
+        },
13
+        columns: [
14
+            { data: "id" },
15
+            { data: "user_id.username" },
16
+            { data: "category_id.name" },
17
+            { data: "content" }
18
+        ]
19
+    });
20
+});
21
+</script>
22
+</head>
23
+<body>
24
+
25
+<table id="example" class="display" style="width:100%">
26
+    <thead>
27
+        <tr>
28
+            <th>ID</th>
29
+            <th>Username</th>
30
+            <th>Category</th>
31
+            <th>Content</th>
32
+        </tr>
33
+    </thead>
34
+    <tfoot>
35
+        <tr>
36
+            <th>ID</th>
37
+            <th>Username</th>
38
+            <th>Category</th>
39
+            <th>Content</th>
40
+        </tr>
41
+    </tfoot>
42
+</table>
43
+
44
+</body>
45
+</html>

Loading…
取消
儲存