Hi everybody
I want to know how I can color the all the lines in my table by clicking on a cell.
I tried this code and the message on console works fine, but the coloration doesn't and I don't understand why:
<%css>
#highlight tr.range-mine td{
color:red;
}
<%css>
<%javascript>
require([
'underscore',
'jquery',
'splunkjs/mvc',
'splunkjs/mvc/tableview',
'splunkjs/mvc/simplexml/ready!'
],function(_,$,mvc,TableView) {
var CustomRangeRenderer = TableView.BaseCellRenderer.extend({
canRender: function(cell){
return _(['id']).contains(cell.field);
},
render: function($td,cell) {
var value = String(cell.value);
if(cell.field === 'id'){
$td.on('click',function(){
console.log('td',value);
$td.addClass('range-cell').addClass('range-mine');
});
}
$td.text(value.split(";")[0]).addClass('text');
}
});
mvc.Components.get('highlight').getVisualization(function(tableView){
tableView.table.addCellRenderer(new CustomRangeRenderer());
tableView.on('rendered',function(){
tableView.$el.find('td.range-cell').each(function(){
$(this).parents('tr').addClass(this.className);
});
});
tableView.table.render();
});
});
<%javascript>
thx
... View more