-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootstrap-table.viewmodel.js
57 lines (54 loc) · 1.41 KB
/
bootstrap-table.viewmodel.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import Map from 'can/map/';
import 'can/map/define/';
import PerformanceMap from 'table-testing/util/performance-map';
export default Map.extend({
define: {
tableData: {
value: {}
},
tableHeaders: {
get(){
let tableData = this.attr("tableData");
return tableData.attr("headers").map((h, i) => {
var objOut = {
id: i,
field: i,
sortable: true,
originalData: h,
width: i == 0 ? 193 : 110
};
if(h instanceof Map){
var n = h.attr("name");
if(n){
objOut.title=n;
objOut.titleTooltip=n;
}
switch (h.type) {
case 'TIME':
objOut.formatter = function(value) {
value = new Date(value);
return value.toLocaleDateString() + " " + value.toLocaleTimeString();
};
break;
case 'KPI':
objOut.formatter = function(value) {
return value ? value.toLocaleString() : value;
};
break;
}
}
return objOut;
})
}
},
tableRows: {
get(){
let tableData = this.attr("tableData");
return tableData.attr("rows");
}
},
performanceMap:{
value: new PerformanceMap()
}
}
});