here is my latest script? any ideas?
require([
'underscore',
'jquery',
'splunkjs/mvc',
'splunkjs/mvc/tableview',
'splunkjs/mvc/simplexml/ready!'
], function(_, $, mvc, TableView) {
var CustomIconRenderer = TableView.BaseCellRenderer.extend({
canRender: function(cell) {
var allowedCells = ["service1","service2", "serviceA", "serviceB", "servicec", "serviced"]
return (allowedCells.indexOf(cell.field)) > -1;
},
render: function($td, cell) {
var count = cell.value;
// Compute the icon base on the field value
var icon;
if(count == "TRUE" || "Running" ) {
icon = 'check';
// } else if(count != TRUE && count != Running) {
// icon = 'severe';
//} else if(count == 100) {
// icon = 'low';
} else {
icon='alert';
}
// Create the icon element and add it to the table cell
$td.addClass('icon-inline numeric').html(_.template('<%- text %> <i class="icon-<%-icon%>"></i>', {
icon: icon,
text: cell.value
}));
}
});
mvc.Components.get('table1').getVisualization(function(tableView){
// Register custom cell renderer
tableView.table.addCellRenderer(new CustomIconRenderer());
// Force the table to re-render
tableView.table.render();
});
});
... View more