Hello everyone.
We have a table where we are inserting an icon in a cell, by javascript, depending on the value that cell.
We have paginated the table, and on the first page, the first time the icons are not displayed, but on the second and subsequent pages they are displayed correctly. They are also shown on the first page if we go back.
**So, the problem is that the icons are not shown on the first page the first time.**
We have tried to put the instruction: **tableView.table.render ();** but in this case, the icons are displayed well on the first page, and they are shown two times on all the other pages, also if we go back to the first page.
![alt text][1]
I think the problem is that for some reason the **render** on the first page does not refresh to show the icons, but we have tried several things and we are not able to get them to be displayed correctly on this first page.
Does anyone know how to fix it?
I include the javascript code:
require([
'jquery',
'underscore',
'splunkjs/mvc',
'splunkjs/mvc/tableview',
'splunkjs/mvc/simplexml/ready!'
], function($, _, mvc, TableView){
mvc.Components.get('kpi_table').getVisualization(function(tableView) {
tableView.on('rendered', function() {
var values = $("#kpi_table").find("td");
values.find(".multivalue-subcell").each(function() { $(this).css("padding","3px"); });
if (values.length > 0)
{
for(var i = 0; i < values.length; i++) {
if($(values[i]).find(".multivalue-subcell").length==0){
$(values[i]).css("vertical-align", "middle");
}
if(parseInt($(values[i]).attr("data-cell-index"))>3 && $(values[i]).find(".multivalue-subcell").length>0) {
var kpi = $(values[i].parentNode).find("td:nth-child(2)")[0].innerText;
var target = parseInt($(values[i].parentNode).find("td:nth-child(3)")[0].innerText.replace("%",""));
var cur_cell = $(values[i]).find(".multivalue-subcell")[0];
var cur_value = parseInt(cur_cell.innerText.replace("%",""));
if(target>0)
{
if(kpi.trim() == "Quality of resolution ratio")
{
if(cur_value <= target)
{
$(cur_cell).append("");
}
else
{
$(cur_cell).append("");
}
}
else
{
if(cur_value >= target)
{
$(cur_cell).append("");
}
else
{
$(cur_cell).append("");
}
}
}
else
{
$(cur_cell).text("N/A");
$(values[i]).attr('data-toggle', 'tooltip');
$(values[i]).attr("title", "Target N/A");
}
}
}
tableView.table.render();
}
});
});
});
Thanks in advance.
[1]: /storage/temp/219817-sin-titulo.png
↧