-
Notifications
You must be signed in to change notification settings - Fork 1
/
tableColsDef.js
72 lines (71 loc) · 1.8 KB
/
tableColsDef.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const colDefs = {
id: {
tableHead: "id",
editable: false,
sortable: true,
width: 50,
hidden: false,
fnCellClass: "text-center"
},
name: {
cellRender: (v, row) => "xx" + v,
tableHead: "Name",
filterEditValue: (newValue, cellValue, row) =>
newValue.replace(/[{]|[}]|[<]|[>]|[\\]|[/]/g, ""),
filterEditChar: (char, cellValue, row) =>
char.match(/[a-zA-ZščřžýáíéóúůďťňĎŇŤŠČŘŽÝÁÍÉÚŮ0-9 ]/),
editable: true,
sortable: true,
width: 200,
fnCellClass: "text-success", // string | list | function returns string or list
thClass: "bg-warning" // string
},
address: {
cellRender: v => v,
tableHead: "Street address",
editable: true,
sortable: true,
width: 200,
fnCellClass: (cv, rw) => {
if (cv) {
if (cv.slice(0, 1) > 5) return "text-primary";
}
}
},
city: {
tableHead: "City",
editable: true,
sortable: true,
width: 200,
fnCellClass: (cv, rwdt) => {
if (rwdt.id % 2) return "text-success font-weight-bold";
return undefined;
}
},
volume: {
tableHead: "Volume",
editable: true,
sortable: true,
width: 100,
filterEditValue: (newValue, cellValue, row) => {
console.log(
"NEW VALUE: ",
Number.parseInt(newValue),
newValue !== Number.parseInt(newValue)
);
if (newValue !== Number.parseInt(newValue, 0)) {
console.log("----------------");
return cellValue;
} else {
return newValue;
}
},
filterEditChar: (char, cellValue, row) => char.match(/[0-9]/),
fnCellClass: (cv, rw) => {
if (cv < 0) return "bg-danger text-white text-right";
return "text-right";
},
thClass: "font-weight-bold text-warning"
}
};
export default colDefs;