forked from wenzhixin/bootstrap-table-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path283.html
95 lines (91 loc) · 2.87 KB
/
283.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
<!DOCTYPE html>
<html>
<head>
<title>Use resetView to reset the header width</title>
<meta charset="utf-8">
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/bootstrap-table/src/bootstrap-table.css">
<link rel="stylesheet" href="assets/examples.css">
<script src="assets/jquery.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/bootstrap-table/src/bootstrap-table.js"></script>
<script src="ga.js"></script>
<style>
.div-table {
/*display: table;*/
border: 1px solid #ccc;
}
.cell-left {
/*display: table-cell;*/
float: left;
width:80%;
}
.cell-right {
/*display: table-cell;*/
float: right;
width:20%;
}
</style>
</head>
<body>
<div class="container">
<div class="ribbon">
<a href="https://github.com/wenzhixin/bootstrap-table-examples/blob/master/283.html" target="_blank">View Source on GitHub</a>
</div>
<h1>Use resetView to reset the header width(<a href="https://github.com/wenzhixin/bootstrap-table/issues/283" target="_blank">#283</a>).</h1>
<p>
<button id="b" type="button" class="btn btn-default">Larger</button>
<button id="s" type="button" class="btn btn-default">Smaller</button>
</p>
<div id="d" class="div-table">
<div class="cell-left">
<table id="table" data-height="500"></table>
</div>
<div class="cell-right">
RRR
</div>
<div class="clearfix"></div>
</div>
</div>
<script>
var $table = $('#table');
$(function () {
buildTable($('#table'), 10, 50);
var $d = $('#d');
var width = $d.width();
$('#b').click(function(){
width = width + 100;
$d.css('width', width + 'px');
$('#table').bootstrapTable('resetView');
});
$('#s').click(function(){
width = width - 100;
$d.css('width', width + 'px');
$('#table').bootstrapTable('resetView');
});
});
function buildTable($el, cells, rows) {
var i, j, row,
columns = [],
data = [];
for (i = 0; i < cells; i++) {
columns.push({
field: 'field' + i,
title: 'Cell' + i
});
}
for (i = 0; i < rows; i++) {
row = {};
for (j = 0; j < cells; j++) {
row['field' + j] = 'Row-' + i + '-' + j;
}
data.push(row);
}
$el.bootstrapTable('destroy').bootstrapTable({
columns: columns,
data: data
});
}
</script>
</body>
</html>