-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathcustom-sort.mjs
42 lines (40 loc) · 945 Bytes
/
custom-sort.mjs
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
import { Grid } from '../../dist/main.esm.js'
export default {
name: 'CustomSort',
components: {
Grid
},
data() {
return {
columns: [
'Name',
'Email',
{
name: 'Phone Number',
sort: {
compare: (a, b) => {
const code = x => x.split(' ')[0]
if (code(a) > code(b)) {
return 1
} else if (code(b) > code(a)) {
return -1
} else {
return 0
}
}
}
}
],
sort: true,
rows: [
['John', '[email protected]', '+353 40 222 3333'],
['Mark', '[email protected]', '+1 22 888 4444'],
['Eoin', '[email protected]', '+355 10 878 5554'],
['Nisen', '[email protected]', '+313 333 1923']
]
}
},
template: `
<div><grid :columns="columns" :rows="rows" :sort="sort"></grid></div>
`
}