-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
82 lines (78 loc) · 3.01 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
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JS Grid</title>
<link rel="stylesheet" href="bootstrap-3.3.6/css/bootstrap.min.css"/>
<link rel="stylesheet" href="font-awesome-4.5.0/css/font-awesome.min.css" />
<link rel="stylesheet" href="grid.css"/>
<script src="grid.js"></script>
</head>
<body>
<div id="dynamicGrid" data-grid></div>
<script>
var createGrid = function (config) {
var _config = {
id: 'dynamicGrid',
fixedHeader: false,
editable: true,
multiselect: false,
dropdowns: [],
columns: [],
data: [],
pagination: {
pageSize: 30
}
};
for (var i in config) {
if(_config.hasOwnProperty(i)){
_config[i] = config[i];
}
}
_config.data = _config.data.concat(_config.data);
_config.data = _config.data.concat(_config.data);
_config.data = _config.data.concat(_config.data);
//_config.data = _config.data.concat(_config.data);
//_config.data = _config.data.concat(_config.data);
//_config.data = _config.data.concat(_config.data);
//_config.data = _config.data.concat(_config.data);
//_config.data = _config.data.concat(_config.data);
//_config.data = _config.data.concat(_config.data);
//_config.data = _config.data.concat(_config.data);
//_config.data = _config.data.concat(_config.data);
//_config.data = _config.data.concat(_config.data);
var template = _config.columns.find(function (obj) {
return obj['fieldname'] == 'price';
})
template['template'] = function (data) {
var color = ''
if (data > 40) {
color = "success";
}
else if(data > 20){
color = "info";
}
else {
color = "danger";
}
return '<span class="bg-'+ color +'">' + data + '</span>';
}
dataGrid = Grid.PrepareGrid(_config);
};
var http = new XMLHttpRequest();
http.open("GET", './data/ds-basic.json');
http.onreadystatechange = function (d) {
if(http.readyState == XMLHttpRequest.DONE && http.status == 200){
var response = JSON.parse(http.responseText);
var config = {
data: response['data'],
selector: 'div[data-grid]',
columns: response['columns'],
dropdowns: response['dropdowns']
};
createGrid(config);
}
};
http.send();
</script>
</body>
</html>