-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
175 lines (175 loc) · 6.45 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="jquery.table.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"
<style>
</style>
<title>jQuery.table test drive</title>
</head>
<body>
<h3>jQuery.table test drive</h3>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script defer="defer" src="jquery.table.js"></script>
<div class="container">
<ol>
<li>自动生成表格
<table class="table table-1">
<thead>
<tr>
<td data-property="@index" style="width: 1em;"></td>
<td data-property="name" style="width: 15em;">名称</td>
<td data-property="input" style="width: 8em;">日期</td>
<td data-property="item" style="width: 15em;">货品</td>
<td data-property="description">描述</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
</li>
<script defer="defer">
$(function () {
var data = [
{"_id": {"oid": "539d60ff2b43b8770000004a"},"name": "2014年6月15日 下午5:00:39 任务","item": [{"_id": {"oid": "536ed2ee0edab7c83b9e79ae"},"name": "马丁"}],"url": "https://www.neurun.com/doctors_office/input_task.html","description": "呵呵","input": {"date": {"date": 1402822911681}}},
{"_id": {"oid": "539d60ff2b43b8770000004a"},"name": "2014年6月15日 下午5:00:39 任务","item": [{"_id": {"oid": "536ed2ee0edab7c83b9e79ae"},"name": "马丁"}],"url": "https://www.neurun.com/doctors_office/input_task.html","description": "呵呵呵","input": {"date": {"date": 1402822911681}}},
{"_id": {"oid": "539d60ff2b43b8770000004a"},"name": "2014年6月20日 下午8:00:39 任务","item": [{"_id": {"oid": "536ed2ee0edab7c83b9e79ae"},"name": "马丁"}],"url": "https://www.neurun.com/doctors_office/input_task.html","description": "呵呵呵","input": {"date": {"date": 1402822911681}}},
{"_id": {"oid": "53a9999a4ca4582000000000"},"name": "2014年6月24日 下午11:30:12 任务","item": [{"_id": {"oid": "536ed2ee0edab7c83b9e79ae"},"name": "外星人 4710 860"}],"url": "http://google.com","description": "呵呵","input": {"date": {"date": 1403623834514}}}
];
$(".table.table-1").table({
source: data,
custom: {
input: $.table.date_n_ip,
item: function(row) {
var ul = $("<ul>");
$(row.item).each(function() {
ul.append($("<li>").text(this.name));
});
return ul;
},
description: function(row) { return $("<td>").html(row.description); }
}
});
});
</script>
<li>表格排序
<table class="table table-2">
<thead>
<tr>
<td data-property="@index" style="width: 1em;"></td>
<td data-property="name" style="width: 15em;">名称</td>
<td data-property="input" style="width: 8em;">日期</td>
<td data-property="item" style="width: 15em;">货品</td>
<td data-property="description">描述</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
</li>
<script defer="defer">
$(function () {
var data = [
{"_id": {"oid": "539d60ff2b43b8770000004a"},"name": "2014年6月15日 下午5:00:39 任务","item": [{"_id": {"oid": "536ed2ee0edab7c83b9e79ae"},"name": "马丁"}],"url": "https://www.neurun.com/doctors_office/input_task.html","description": "呵呵","input": {"date": {"date": 1402822911681}}},
{"_id": {"oid": "539d60ff2b43b8770000004a"},"name": "2014年6月15日 下午5:00:39 任务","item": [{"_id": {"oid": "536ed2ee0edab7c83b9e79ae"},"name": "马丁"}],"url": "https://www.neurun.com/doctors_office/input_task.html","description": "呵呵呵","input": {"date": {"date": 1402822911681}}},
{"_id": {"oid": "539d60ff2b43b8770000004a"},"name": "2014年6月20日 下午8:00:39 任务","item": [{"_id": {"oid": "536ed2ee0edab7c83b9e79ae"},"name": "马丁"}],"url": "https://www.neurun.com/doctors_office/input_task.html","description": "呵呵呵","input": {"date": {"date": 1402822911681}}},
{"_id": {"oid": "53a9999a4ca4582000000000"},"name": "2014年6月24日 下午11:30:12 任务","item": [{"_id": {"oid": "536ed2ee0edab7c83b9e79ae"},"name": "外星人 4710 860"}],"url": "http://google.com","description": "呵呵","input": {"date": {"date": 1403623834514}}}
];
$(".table.table-2").table({
source: data,
sort: {
name: true, input: "input.date.date"
},
custom: {
input: $.table.date_n_ip,
item: function(row) {
var ul = $("<ul>");
$(row.item).each(function() {
ul.append($("<li>").text(this.name));
});
return ul;
},
description: function(row) { return $("<td>").html(row.description); }
}
});
});
</script>
<li>部分载入
<table class="table table-3">
<thead>
<tr>
<td data-property="@index" style="width: 3em;"></td>
<td data-property="name" style="width: 15em;">名称</td>
<td data-property="input" style="width: 8em;">日期</td>
<td data-property="description">描述</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
</li>
<script defer="defer">
$(function () {
var pos = 0, template = {"_id": {"oid": "539d60ff2b43b8770000004a"},"name": "name ","description":"description ", "input": 0};
$(".table.table-3").table({
source: function() {
var results = { $skip: pos, $limit: 2, $count: 100 },
array = results.$array = [];
for (var i = 0, limit = results.$limit; i < limit; i++) {
var r = $.extend({}, template);
r.name += (i + pos);
r.description += (i + pos);
r.input += i % 6;
array.push(r);
}
pos += results.$limit;
return results;
},
sort: {
name: true, input: true
}
});
});
</script>
<li>部分载入(大数据量)
<table class="table table-4">
<thead>
<tr>
<td data-property="@index" style="width: 3em;"></td>
<td data-property="name" style="width: 15em;">名称</td>
<td data-property="input" style="width: 8em;">日期</td>
<td data-property="description">描述</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
</li>
<script defer="defer">
$(function () {
var pos = 0, template = {"_id": {"oid": "539d60ff2b43b8770000004a"},"name": "name ","description":"description ", "input": 0};
$(".table.table-4").table({
source: function() {
var results = { $skip: pos, $limit: 100, $count: 1000 },
array = results.$array = [];
for (var i = 0, limit = results.$limit; i < limit; i++) {
var r = $.extend({}, template);
r.name += (i + pos);
r.description += (i + pos);
r.input += i % 6;
array.push(r);
}
pos += results.$limit;
return results;
},
sort: {
name: true, input: true
}
});
});
</script>
</ol>
</div>
</body>
</html>