1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | (function ($) {
|
12 |
|
13 | $.extend(true, window, {
|
14 | "Slick": {
|
15 | "Formatters": {
|
16 | "PercentComplete": PercentCompleteFormatter,
|
17 | "PercentCompleteBar": PercentCompleteBarFormatter,
|
18 | "YesNo": YesNoFormatter,
|
19 | "Checkmark": CheckmarkFormatter,
|
20 | "Checkbox": CheckboxFormatter
|
21 |
|
22 | }
|
23 | }
|
24 | });
|
25 |
|
26 | function PercentCompleteFormatter(row, cell, value, columnDef, dataContext) {
|
27 | if (value == null || value === "") {
|
28 | return "-";
|
29 | } else if (value < 50) {
|
30 | return "<span style='color:red;font-weight:bold;'>" + value + "%</span>";
|
31 | } else {
|
32 | return "<span style='color:green'>" + value + "%</span>";
|
33 | }
|
34 | }
|
35 |
|
36 | function PercentCompleteBarFormatter(row, cell, value, columnDef, dataContext) {
|
37 | if (value == null || value === "") {
|
38 | return "";
|
39 | }
|
40 |
|
41 | var color;
|
42 |
|
43 | if (value < 30) {
|
44 | color = "red";
|
45 | } else if (value < 70) {
|
46 | color = "silver";
|
47 | } else {
|
48 | color = "green";
|
49 | }
|
50 |
|
51 | return "<span class='percent-complete-bar' style='background:" + color + ";width:" + value + "%'></span>";
|
52 | }
|
53 |
|
54 | function YesNoFormatter(row, cell, value, columnDef, dataContext) {
|
55 | return value ? "Yes" : "No";
|
56 | }
|
57 |
|
58 | function CheckboxFormatter(row, cell, value, columnDef, dataContext) {
|
59 | return '<img class="slick-edit-preclick" src="../images/' + (value ? "CheckboxY" : "CheckboxN") + '.png">';
|
60 | }
|
61 |
|
62 | function CheckmarkFormatter(row, cell, value, columnDef, dataContext) {
|
63 | return value ? "<img src='../images/tick.png'>" : "";
|
64 | }
|
65 | })(jQuery);
|