You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.5 KiB
59 lines
1.5 KiB
/*** |
|
* Contains basic SlickGrid formatters. |
|
* |
|
* NOTE: These are merely examples. You will most likely need to implement something more |
|
* robust/extensible/localizable/etc. for your use! |
|
* |
|
* @module Formatters |
|
* @namespace Slick |
|
*/ |
|
|
|
(function ($) { |
|
// register namespace |
|
$.extend(true, window, { |
|
"Slick": { |
|
"Formatters": { |
|
"PercentComplete": PercentCompleteFormatter, |
|
"PercentCompleteBar": PercentCompleteBarFormatter, |
|
"YesNo": YesNoFormatter, |
|
"Checkmark": CheckmarkFormatter |
|
} |
|
} |
|
}); |
|
|
|
function PercentCompleteFormatter(row, cell, value, columnDef, dataContext) { |
|
if (value == null || value === "") { |
|
return "-"; |
|
} else if (value < 50) { |
|
return "<span style='color:red;font-weight:bold;'>" + value + "%</span>"; |
|
} else { |
|
return "<span style='color:green'>" + value + "%</span>"; |
|
} |
|
} |
|
|
|
function PercentCompleteBarFormatter(row, cell, value, columnDef, dataContext) { |
|
if (value == null || value === "") { |
|
return ""; |
|
} |
|
|
|
var color; |
|
|
|
if (value < 30) { |
|
color = "red"; |
|
} else if (value < 70) { |
|
color = "silver"; |
|
} else { |
|
color = "green"; |
|
} |
|
|
|
return "<span class='percent-complete-bar' style='background:" + color + ";width:" + value + "%'></span>"; |
|
} |
|
|
|
function YesNoFormatter(row, cell, value, columnDef, dataContext) { |
|
return value ? "Yes" : "No"; |
|
} |
|
|
|
function CheckmarkFormatter(row, cell, value, columnDef, dataContext) { |
|
return value ? "<img src='../images/tick.png'>" : ""; |
|
} |
|
})(jQuery);
|
|
|