-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnumericColor.js
37 lines (30 loc) · 1.1 KB
/
numericColor.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
/** start addIn numericColor **/
var numericColor = {
name: "numericColor",
label: "numeric Color",
defaults: {
decimal: true,
textFormat: function(v, st, opt, objectHtml) {
var value= v;
/** Condition for coloring **/
if (value < 500) {
$(objectHtml).css({'background-color':'red'});
} else if (value < 1000){
$(objectHtml).css({'background-color':'blue'});
} else {
$(objectHtml).css({'background-color':'green'});
}
return "<span style='text-align:right;'>"+value+"</span>";
}
},
init: function(){
$.fn.dataTableExt.oSort[this.name+'-asc'] = $.fn.dataTableExt.oSort['numeric-asc'];
$.fn.dataTableExt.oSort[this.name+'-desc'] = $.fn.dataTableExt.oSort['numeric-desc'];
},
implementation: function(tgt, st, opt){
var text = opt.textFormat.call(this, st.value, st, opt, tgt);
$(tgt).empty().append(text);
}
};
Dashboards.registerAddIn("Table", "colType", new AddIn(numericColor));
/** end addIn numericColor **/