This is the js file, I am enabling tooltip on columns starts with list of and for all tables that ends with with_tooltip
require([
'underscore',
'jquery',
'splunkjs/mvc',
'splunkjs/mvc/tableview',
'splunkjs/mvc/simplexml/ready!'
], function(_, $, mvc, TableView) {
var CustomTooltipRenderer = TableView.BaseCellRenderer.extend({
canRender: function(cell) {
var re = /list\s*of.*/i;
var result = cell.field.match(re);
if(result){
return cell.field;
}
return
},
render: function($td, cell) {
var message = cell.value;
var tip = cell.value;
if(message.length > 15) { message = message.substring(0,14) + "..."
$td.html(_.template('<a href="#" data-toggle="tooltip" data-placement="left auto" title="<%- tip%>"><%- message%></a>', {
tip: tip,
message: message
}));
$td.children('[data-toggle="tooltip"]').tooltip();
}
else{
$td.html(_.template(message, {
tip: tip,
message: message
}));
}
}
});
var tableIDs = [];
var domeElements = document.getElementsByTagName("div");
for(var i=0;i<domeElements.length;i++)
{
if(domeElements[i].id != "undefined" && domeElements[i].id.match(/.*with_tooltip$/i)){
tableIDs.push(domeElements[i].id);
}
}
for(i = 0; i < tableIDs.length; i++){
mvc.Components.get(tableIDs[i]).getVisualization(function(tableView) {
tableView.table.addCellRenderer(new CustomTooltipRenderer());
tableView.table.render();
});
}
});
It shows something like this, My guess is it's missing some of bootstrap libraries or I am doing something wrong.
... View more