-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.html
More file actions
154 lines (132 loc) · 3.82 KB
/
example.html
File metadata and controls
154 lines (132 loc) · 3.82 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>React smart table example</title>
<!-- css -->
<link rel="stylesheet" href="react_smart_table.css" >
<!-- js -->
<script src="https://fb.me/react-0.13.1.js"></script>
<script src="react_smart_table.js"></script>
<script src="https://cdn.rawgit.com/eligrey/FileSaver.js/master/FileSaver.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<!-- Optional theme
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">
-->
<!-- Latest compiled and minified JavaScript
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
-->
<style>
/* html, body{
margin:10px;
height: 100%;
}*/
div#fixed_table{
width:200px;
height:150px;
margin:10px;
padding:5px;
border:5px solid black;
}
div#auto_table{
height:200px;
margin:10px;
padding:5px;
border:5px solid black;
}
div#fill_table{
}
</style>
</head>
<body>
<!-- page content -->
<div>width=200 height=150</div>
<div id="fixed_table"></div>
<div>(width="auto") height=200 </div>
<div id="auto_table"></div>
<div>height="fill" (width="auto")</div>
<div id="fill_table"></div>
</div>
<script>
function randomString(length)
{
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ";
for( var i=0; i < length; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
//generate a random dataset
var rowCount = 1000;
var columnCount = 5;
var items = [];
for(var row=0; row<rowCount;row++)
{
var item = {};
item["id"] = row;
for(var col=0; col<columnCount;col++)
{
// generate bad/incomplete data in the stock
if(Math.floor(Math.random() *100) % 5 == 0)
continue;
else if(Math.floor(Math.random() *100) % 6 == 0)
item["column_"+col] = null;
else if(Math.floor(Math.random() *100) % 7 == 0)
item["column_"+col] = undefined;
else
item["column_"+col] = randomString(3);
}
items.push(item);
}
//generate column configs
var fixedColumns = [{
width:50,
dataKey:"id",
label:"ID"
}];
var columns = [];
for(var col=0; col<columnCount;col++)
{
columns.push({
width:80,
dataKey:"column_"+col
});
}
React.render(
ReactSmartTable.Table({
//width:100
height:"100%",
autoGenerateColumns:true,
fixedColumns:fixedColumns,
columns:columns,
items:items,
footerPresent:false
}),
document.getElementById('fixed_table')
);
React.render(
ReactSmartTable.Table({
height:'100%',
autoGenerateColumns:true,
fixedColumns:fixedColumns,
columns:columns,
items:items
}),
document.getElementById('auto_table')
);
React.render(
ReactSmartTable.Table({
height:"fill",
offsetBottom:20,
autoGenerateColumns:true,
fixedColumns:fixedColumns,
columns:columns,
items:items
}),
document.getElementById('fill_table')
);
window.React = React;
</script>
</body>
</html>