forked from mbest/knockout-table
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
127 lines (103 loc) · 3.54 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
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
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/knockout/knockout-2.2.1.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
<script type="text/javascript" src="knockout-table.js"></script>
<style type="text/css">
.unselectable {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
cursor: pointer;
}
.selected {
background-color: #4bb1cf;
}
th > span{
display: block;
}
th {
text-align: center;
}
</style>
</head>
<body>
<script type="text/javascript">
function TableModel() {
var self = this;
var limit = 100;
self.addRow = function () {
for (var i = 0; i < 1; i++) {
self.data.push([Math.random(), Math.random(), Math.random()]);
}
};
self.speedAddRow = function () {
var ar = [];
for (var i = 0; i < limit; i++) {
ar.push([Math.random(), Math.random(), Math.random()]);
}
ko.utils.arrayPushAll(self.data, ar);
};
self.data = ko.observableArray([
['scuola','fratello','sorella'],
['milan','juventus','inter'],
['cugino','cugina','nonno'],
['zio','zia','scout'],
['adsl','cellulare','telefono'],
['penna','pennarello','matita'],
['colore','arancione','giallo'],
['usb','foglio','libro'],
['computer','sentiero','chiavetta'],
['tastiera','roma','lazio'],
['catania','fiorentina','cagliari'],
['inglese','francese','maglia'],
['random','fse','edoardo puzza'],
['quaderno','barcellona','tablet'],
['sbadaraggafa','ciao','come'],
['cesena','roma','napoli'],
['terrazzo','casa','lavatrice'],
['sto','lontano','dallo'],
['stress','fumo','un'],
['pò','e','dopo'],
['gioco','a','pes'],
['pato','mexes','messi'],
['valdes','fumo','un'],
['pò','e','dopo'],
['gioco','a','pes']
]);
self.header = ko.observableArray(["a", "b", "c"]);
self.searchText = ko.observable('');
self.sortFunc = function(left, right, index, desc) {
};
}
;
$(document).ready(function () {
var vm = new TableModel();
ko.applyBindings(vm);
});
</script>
<button data-bind="click: addRow">Add row</button>
<button data-bind="click: speedAddRow">Add row fast</button>
<input type="text" data-bind="value: searchText, valueUpdate: 'afterkeydown'"/>
<br/>
<table data-bind="table:
{
data: data,
header: header,
headerClass: 'unselectable',
upClass: 'icon icon-circle-arrow-up',
downClass: 'icon icon-circle-arrow-down',
hideClass: 'hide',
searchText: searchText,
sortFunc: sortFunc
}"
class="table table-hover table-condensed">
</table>
</body>
</html>