Reply to @jbrodsky_splunk
I tried to paste it in the comment but char count exceeded. Here's the javascript.
require([
'underscore',
'jquery',
'splunkjs/mvc',
'splunkjs/mvc/tableview',
'splunkjs/mvc/simplexml/ready!'
], function(_, $, mvc, TableView) {
// Row Coloring Example with custom, client-side range interpretation
var CustomRangeRenderer = TableView.BaseCellRenderer.extend({
canRender: function(cell) {
// Enable this custom cell renderer for both the active_hist_searches and the active_realtime_searches field
return _(['CentralFlorida','Cleveland','GulfCoast','LasVegas','NorthernVirginia','OklahomaCity','Phoenix','SanDiego','SantaBarbara','BatonRouge','Connecticut','HamptonRoads','Macon','NewOrleans','Omaha','OrangeCounty','RhodeIsland','Roanoke','Tulsa','Wichita','all_markets']).contains(cell.field);
},
render: function($td, cell) {
// Add a class to the cell based on the returned value
//alert(cell);
var value = parseFloat(cell.value);
// Apply interpretation for number of historical searches
//alert(value);
//CentralFlorida
if (cell.field !== ' ') {
if (value >= 99) {
$td.addClass('range-cell').addClass('green');
}
else if (value >= 98 && value < 99 ) {
$td.addClass('range-cell').addClass('amber');
}
else if (value < 98 ) {
$td.addClass('range-cell').addClass('red');
}
}
// Update the cell content
$td.text(value.toFixed(2)).addClass('numeric');
}
});
mvc.Components.get('bixlaxrates').getVisualization(function(tableView) {
// Add custom cell renderer
tableView.table.addCellRenderer(new CustomRangeRenderer());
// tableView.on('rendered', function() {
// Apply class of the cells to the parent row in order to color the whole row
// tableView.$el.find('td.range-cell').each(function() {
// $(this).addClass(this.className);
// });
//});
// Force the table to re-render
tableView.table.render();
});
mvc.Components.get('bizrates').getVisualization(function(tableView) {
// Add custom cell renderer
tableView.table.addCellRenderer(new CustomRangeRenderer());
// tableView.on('rendered', function() {
// Apply class of the cells to the parent row in order to color the whole row
// tableView.$el.find('td.range-cell').each(function() {
// $(this).addClass(this.className);
// });
//});
// Force the table to re-render
tableView.table.render();
});
mvc.Components.get('techrates').getVisualization(function(tableView) {
// Add custom cell renderer
tableView.table.addCellRenderer(new CustomRangeRenderer());
// tableView.on('rendered', function() {
// Apply class of the cells to the parent row in order to color the whole row
// tableView.$el.find('td.range-cell').each(function() {
// $(this).addClass(this.className);
// });
//});
// Force the table to re-render
tableView.table.render();
});
});
... View more