-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.html
More file actions
150 lines (110 loc) · 3.57 KB
/
demo.html
File metadata and controls
150 lines (110 loc) · 3.57 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
<!doctype html>
<html>
<head>
<title>ui-grid</title>
<link rel="import" href="node_modules/polymer/polymer.html">
<link rel="import" href="src/ui-grid.html">
<link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
</head>
<style>
html, body {
height: 100%;
margin: 0;
font-family: 'Roboto', sans-serif;
}
body {
padding: 10px;
}
ui-grid {
width: 800px;
height: 400px;
}
ui-grid /deep/ grid-header {
background-color: #2196F3;
color: white;
}
ui-grid /deep/ [sort] {
color: #1976D2;
}
section {
width: 600px;
}
</style>
<body>
<h1>A (virtualized) grid for you!</h1>
<section>
Row virtualization allows you to render large quantities of data without putting large quanitites of
DOM elements into the page. This essentially works by mutating the data that is bound to each row as the view
scrolls. The table is really just made up of the rows you see in the page plus a small buffer on each side.
Once a full "page" of data is scrolled off the page, the rows shift back up to the top of the buffer and recycle.
<br/>
<br/>
Using the following data:
<br/>
<br/>
<script src="https://gist.github.com/sayeefb/5e687edd0a7660663cfb.js"></script>
<br/>
And this snippet of html and javascript:
<br/>
<br/>
<script src="https://gist.github.com/sayeefb/85a64c18cc0fa3e6d501.js"></script>
You too can make a spectacular virtualized table!
<br/>
<br/>
<ui-grid rowheight="50" height="400" selectionEnabled="true" multiSelect="true"></ui-grid>
</section>
<section>
<h2>Cell Templating</h2>
The first example is great but it only programmatically renders each cell the same.
Cell templating allows us to customize each column independently.
<br/>
<br/>
<script src="https://gist.github.com/sayeefb/fbad904d87278ab8f33d.js"></script>
Now marvel at this spectacular sight!
<br/>
<br/>
<ui-grid rowheight="50" height="400">
<template column-override name="a">
<b>♥{{model.a}}</b>
</template>
</ui-grid>
<br/>
</section>
<section>
<h3>Todo</h3>
So there is bunch of stuff that we need to finish up on this.
<ul>
<li>Multi-sort (Need to port solution from consultations) <a href="https://github.com/glg/consultations/blob/starphleet/public/js/controllers/dashboards/Volumizer.coffee#L90">Linked!</a></li>
<li>Header template overrides (Copying column override code)</li>
<li>Resizeable column widths using core-resizeable</li>
</ul>
</section>
</body>
<script>
document.addEventListener('polymer-ready', function() {
var tables = document.querySelectorAll('ui-grid').array();
tables.forEach(function(table) {
var data = [];
for (var i = 0; i < 1000; i++) {
var keys = [ 'a', 'b', 'c', 'd', 'e', 'f' ];
var row = keys.reduce(function(acc,key,j) {
acc[key] = key+i;
return acc;
},{})
data.push(row);
}
table.value = data;
var events = [
'cellclick',
'celldblclick',
'headerclick',
'headerdblclick',
'gridvaluechanged'
]
events.forEach(function (event) {
table.addEventListener(event, function() { console.log(arguments) });
});
});
})
</script>
</html>