In my dashboard, I have to highlight the cells that have a value greater than the value selected by the user. I am not sure how to do it.
I tried doing the code but it is not working. I have attached the js and xml code below
<form script="testexception11.js" stylesheet="ptilecolors.css">
<label>newtesttable</label>
<fieldset autoRun="true" submitButton="true">
<input type="dropdown" token="adjhours" searchWhenChanged="true">
<label>test</label>
<choice value="100">100%</choice>
<choice value="200">200%</choice>
<choice value="300">300%</choice>
<choice value="1000">1000%</choice>
<choice value="10000">10000%</choice>
<default>10000</default>
</input>
</fieldset>
<row>
<panel>
<table id="hourtab">
<search>
<query>index="_internal"|stats count as TOTAL_COUNT by sourcetype</query>
<earliest>-24h@h</earliest>
<latest>now</latest>
<sampleRatio>1</sampleRatio>
</search>
<option name="count">20</option>
<option name="dataOverlayMode">none</option>
<option name="drilldown">none</option>
<option name="percentagesRow">false</option>
<option name="rowNumbers">false</option>
<option name="totalsRow">false</option>
<option name="wrap">true</option>
</table>
</panel>
</row>
</form>
JavaScript
require([
'underscore',
'jquery',
'splunkjs/mvc',
'splunkjs/mvc/tableview',
'splunkjs/mvc/simplexml/ready!'
],
function (_, $, mvc, TableView) {
// Access the "default" token model
var tokens = mvc.Components.get("default");
tokens.on("change:adjhours",function(){
var hoursvalue=Number(tokens.get("adjhours"));
console.log("xyz",hoursvalue);
var renderhourtab = TableView.BaseCellRenderer.extend({
canRender: function(cell) {
return true;
},
render: function($td, cell) {
var cellcontent = Number(cell.value);
if (cell.field == 'TOTAL_COUNT'){ //check if the field name conatins %Adjusted
if (cellcontent > hoursvalue){
$td.addClass('Red');
}
else {
$td.addClass('Purple');
}
}
// Update the cell content
$td.text(cell.value)
}
});
console.log(1);
var mytab = mvc.Components.get("hourtab");
mytab.getVisualization(function(tableView){
tableView.table.addCellRenderer(new renderhourtab());
tableView.table.render();
});
console.log(2);
});
console.log(3);
});
... View more