-
Notifications
You must be signed in to change notification settings - Fork 13
/
fresh-table-tutorial.html
423 lines (385 loc) · 17.1 KB
/
fresh-table-tutorial.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" type="image/png" href="/fresh-bootstrap-table/assets/img/favicon.ico">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>Fresh Bootstrap Table by Creative Tim</title>
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
<!-- Canonical SEO -->
<link rel="canonical" href="https://www.creative-tim.com/product/fresh-bootstrap-table"/>
<link href="/fresh-bootstrap-table/assets/css/bootstrap.css" rel="stylesheet" />
<link href="/fresh-bootstrap-table/assets/css/fresh-bootstrap-table.css" rel="stylesheet" />
<link href="/fresh-bootstrap-table/assets/css/demo.css" rel="stylesheet" />
<!-- Fonts and icons -->
<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Roboto:400,700,300' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="/fresh-bootstrap-table/assets/js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="/fresh-bootstrap-table/assets/js/bootstrap.js"></script>
<script type="text/javascript" src="/fresh-bootstrap-table/assets/js/bootstrap-table.js"></script>
<!-- Just for demo purpose, do not include in your project -->
<script type="text/javascript" src="/fresh-bootstrap-table/assets/js/demo/gsdk-switch.js"></script>
<script type="text/javascript" src="/fresh-bootstrap-table/assets/js/demo/jquery.sharrre.js"></script>
<script type="text/javascript" src="/fresh-bootstrap-table/assets/js/demo/demo.js"></script>
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
<style>
body{
color: #FFFFFF;
}
.logo-container .brand{
color: #FFFFFF;
}
a{
color: #555555;
}
a:hover,
a:focus{
color: #444;
}
.fa-heart{
color: #F74933;
}
.space-100{
height: 100px;
display: block;
}
.space-50{
height: 50px;
display: block;
}
pre.prettyprint{
background-color: #444;
border: 1px solid #343434;
margin-top: 20px;
padding: 20px;
text-align: left;
}
.atv, .str{
color: #25C6EC;
}
.tag, .pln, .kwd{
color: #7A8CB2;
}
.atn{
color: #2C93FF;
}
.pln{
color: #EEEEEE;
}
.com{
color: #999;
}
.pun, .opn, .clo {
color: #C3C3C3;
}
.btn-neutral.btn-fill, .btn-neutral.btn-fill:hover, .btn-neutral.btn-fill:focus{
color: #555555;
}
</style>
</head>
<body>
<a href="http://creative-tim.com">
<div class="logo-container">
<div class="logo">
<img src="fresh-bootstrap-table/assets/img/new_logo.png">
</div>
<div class="brand">
Creative Tim
</div>
</div>
</a>
<div class="main">
<div class="container tim-container" style="max-width:800px; padding-top:100px">
<h1 class="text-center">Fresh Bootstrap Table - Tutorial<br>
<small>This tutorial was made to make the integration as easy as possible.</small>
</h1>
<div class="col-md-12">
<br>
<h4>
We restyled the classic Bootstrap Table and made it look fresh and bright. Here are the files that you need to add in your project.
</h4>
<pre class="prettyprint">
<head>
<!-- Style -->
<link href="assets/css/bootstrap.css" rel="stylesheet" />
<link href="assets/css/fresh-bootstrap-table.css" rel="stylesheet" />
<!-- Fonts and icons -->
<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Roboto:400,700,300' rel='stylesheet' type='text/css'>
</head>
</pre>
<br>
<h4>
This is the main HTML code for the Fresh Bootstrap Table. You can create a table with any data or whatever you want. More details about the methods, data manipulations or functions available with this Bootstrap Table can be found <a href="http://bootstrap-table.wenzhixin.net.cn/">here.</a>
</h4>
<pre class="prettyprint">
<div class="fresh-table full-color-orange">
<!-- Available colors for the full background: full-color-blue, full-color-azure, full-color-green, full-color-red, full-color-orange
Available colors only for the toolbar: toolbar-color-blue, toolbar-color-azure, toolbar-color-green, toolbar-color-red, toolbar-color-orange
-->
<div class="toolbar">
<button id="alertBtn" class="btn btn-default">Alert</button>
</div>
<table id="fresh-table" class="table">
<thead>
<th data-field="id">ID</th>
<th data-field="name">Name</th>
<th data-field="salary">Salary</th>
<th data-field="country">Country</th>
<th data-field="city">City</th>
<th data-field="actions" data-formatter="operateFormatter" data-events="operateEvents">Actions</th>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Dakota Rice</td>
<td>$36,738</td>
<td>Niger</td>
<td>Oud-Turnhout</td>
<td></td>
</tr>
<tr>
<td>2</td>
<td>Minerva Hooper</td>
<td>$23,789</td>
<td>Curaçao</td>
<td>Sinaai-Waas</td>
<td></td>
</tr>
<tr>
<td>3</td>
<td>Sage Rodriguez</td>
<td>$56,142</td>
<td>Netherlands</td>
<td>Baileux</td>
<td></td>
</tr>
<tr>
<td>4</td>
<td>Philip Chaney</td>
<td>$38,735</td>
<td>Korea, South</td>
<td>Overland Park</td>
<td></td>
</tr>
<tr>
<td>5</td>
<td>Doris Greene</td>
<td>$63,542</td>
<td>Malawi</td>
<td>Feldkirchen in Kärnten</td>
<td></td>
</tr>
<tr>
<td>6</td>
<td>Mason Porter</td>
<td>$78,615</td>
<td>Chile</td>
<td>Gloucester</td>
<td></td>
</tr>
<tr>
<td>7</td>
<td>Alden Chen</td>
<td>$63,929</td>
<td>Finland</td>
<td>Gary</td>
<td></td>
</tr>
<tr>
<td>8</td>
<td>Colton Hodges</td>
<td>$93,961</td>
<td>Nicaragua</td>
<td>Delft</td>
<td></td>
</tr>
<tr>
<td>9</td>
<td>Illana Nelson</td>
<td>$56,142</td>
<td>Heard Island</td>
<td>Montone</td>
<td></td>
</tr>
<tr>
<td>10</td>
<td>Nicole Lane</td>
<td>$93,148</td>
<td>Cayman Islands</td>
<td>Cottbus</td>
<td></td>
</tr>
<tr>
<td>11</td>
<td>Chaim Saunders</td>
<td>$5,502</td>
<td>Romania</td>
<td>New Quay</td>
<td></td>
</tr>
<tr>
<td>12</td>
<td>Josiah Simon</td>
<td>$50,265</td>
<td>Christmas Island</td>
<td>Sint-Jans-Molenbeek</td>
<td></td>
</tr>
<tr>
<td>13</td>
<td>Ila Poole</td>
<td>$67,413</td>
<td>Montenegro</td>
<td>Pontevedra</td>
<td></td>
</tr>
<tr>
<td>14</td>
<td>Shana Mejia</td>
<td>$58,566</td>
<td>Afghanistan</td>
<td>Ballarat</td>
<td></td>
</tr>
<tr>
<td>15</td>
<td>Lana Ryan</td>
<td>$64,151</td>
<td>Martinique</td>
<td>Portobuffolè</td>
<td></td>
</tr>
<tr>
<td>16</td>
<td>Daquan Bender</td>
<td>$91,906</td>
<td>Sao Tome and Principe</td>
<td>Walhain-Saint-Paul</td>
<td></td>
</tr>
<tr>
<td>17</td>
<td>Connor Wagner</td>
<td>$86,537</td>
<td>Germany</td>
<td>Solihull</td>
<td></td>
</tr>
<tr>
<td>18</td>
<td>Boris Horton</td>
<td>$35,094</td>
<td>Laos</td>
<td>Saint-Mard</td>
<td></td>
</tr>
<tr>
<td>19</td>
<td>Winifred Ryan</td>
<td>$64,436</td>
<td>Ireland</td>
<td>Ronciglione</td>
<td></td>
</tr>
</tbody>
</table>
</div>
</pre>
<br>
<h4>
Here are the javascript files that you have to include and the Javascript plugin that you have to call in your page. The core code for the Fresh Bootstrap Table can be found in the 'bootstrap-table.js'. Here is the code for initialising the table in your page:
</h4>
<pre class="prettyprint">
<!-- Javascript -->
<script type="text/javascript" src="assets/js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="assets/js/bootstrap.js"></script>
<script type="text/javascript" src="assets/js/bootstrap-table.js"></script>
<script type="text/javascript">
var $table = $('#fresh-table'),
$alertBtn = $('#alertBtn'),
full_screen = false;
$().ready(function(){
$table.bootstrapTable({
toolbar: ".toolbar",
showRefresh: true,
search: true,
showToggle: true,
showColumns: true,
pagination: true,
striped: true,
sortable: true,
pageSize: 8,
pageList: [8,10,25,50,100],
formatShowingRows: function(pageFrom, pageTo, totalRows){
//do nothing here, we don't want to show the text "showing x of y from..."
},
formatRecordsPerPage: function(pageNumber){
return pageNumber + " rows visible";
},
icons: {
refresh: 'fa fa-refresh',
toggle: 'fa fa-th-list',
columns: 'fa fa-columns',
detailOpen: 'fa fa-plus-circle',
detailClose: 'fa fa-minus-circle'
}
});
});
$(function () {
$alertBtn.click(function () {
alert("You pressed on Alert");
});
});
function operateFormatter(value, row, index) {
return [
'<a rel="tooltip" title="Like" class="table-action like" href="javascript:void(0)" title="Like">',
'<i class="fa fa-heart"></i>',
'</a>',
'<a rel="tooltip" title="Edit" class="table-action edit" href="javascript:void(0)" title="Edit">',
'<i class="fa fa-edit"></i>',
'</a>',
'<a rel="tooltip" title="Remove" class="table-action remove" href="javascript:void(0)" title="Remove">',
'<i class="fa fa-remove"></i>',
'</a>'
].join('');
}
window.operateEvents = {
'click .like': function (e, value, row, index) {
alert('You click like icon, row: ' + JSON.stringify(row));
console.log(value, row, index);
},
'click .edit': function (e, value, row, index) {
console.log(value, row, index);
},
'click .remove': function (e, value, row, index) {
alert('You click remove icon, row: ' + JSON.stringify(row));
console.log(value, row, index);
}
};
</script>
</pre>
<h4>
Besides the default style, we added 5 new colors for the background of Fresh Bootstrap Table and for it's Toolbar: <b>blue</b>, <b>azure</b>, <b>green</b>, <b>orange</b>, <b>red</b>. If you want to use one of them, you can use the class for the chosen color: "full-color-{<b>blue | azure | green | orange | red</b>}" or "toolbar-color-{<b>blue | azure | green | orange | red</b>}".
<br><br>
If you want to use the table as Full Screen you have to add the class "<b>full-screen-table</b>" for the save "<b>div</b>" that has the class "<b>fresh-table</b>".
</h4>
<h4>Many thanks to our friend for open sourcing the base for this Bootstrap Table. More details can be found here <a href="http://bootstrap-table.wenzhixin.net.cn/">here.</a>
</h4>
<h4>Get more useful items for Bootstrap on <a href="http://creative-tim.com">Creative Tim.</a></h4>
</div>
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm-4">
<div class="space-50"></div>
<a href="http://creative-tim.com/product/fresh-bootstrap-table" class="btn btn-neutral btn-fill btn-lg btn-block">Free Download</a>
</div>
<div class="col-sm-4"></div>
</div>
<div class="space-100"></div>
<p class="text-center">Copyright © 2015 <a href="http://creative-tim.com">Creative Tim</a>, made with <i class="fa fa-heart"></i> for a better web.</p>
<!-- end container -->
</div>
<!-- end main -->
</body>
</html>