forked from vuejs/vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrid.js
41 lines (40 loc) · 851 Bytes
/
grid.js
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
// register the grid component
Vue.component('demo-grid', {
template: '#grid-template',
replace: true,
data: function () {
return {
columns: null,
sortKey: '',
filterKey: '',
reversed: {}
}
},
compiled: function () {
// initialize reverse state
var self = this
this.columns.forEach(function (key) {
self.reversed.$add(key, false)
})
},
methods: {
sortBy: function (key) {
this.sortKey = key
this.reversed[key] = !this.reversed[key]
}
}
})
// bootstrap the demo
var demo = new Vue({
el: '#demo',
data: {
search: '',
gridColumns: ['name', 'power'],
gridData: [
{ name: 'Chuck Norris', power: Infinity },
{ name: 'Bruce Lee', power: 9000 },
{ name: 'Jacky Chang', power: 7000 },
{ name: 'Jet Li', power: 8000 }
]
}
})