Dashboards & Visualizations

Table cell renderer does not work on Firefox

VatsalJagani
SplunkTrust
SplunkTrust

I've very similar javascript as below in my dashboard which adds up the color in the table. As I've updated dashboard.css I cannot utilize XML color palette, so I had to use table cell renderer.

require([
     'underscore',
     'jquery',
     'splunkjs/mvc',
     'splunkjs/mvc/tableview',
     'splunkjs/mvc/simplexml/ready!'
 ], function(_, $, mvc, TableView) {

     var CustomRangeRenderer = TableView.BaseCellRenderer.extend({
         canRender: function(cell) {
             // Point-C
             return _(['My Column Name', 'Name']).contains(cell.field);
         },
         render: function($td, cell) {
             // Point-D
             if(cell.value=="red" || cell.value=="green" || cell.value=="yellow")
             {
                 $td.html("<div class='circle_"+cell.value+"'></div>")
             }
             else if(cell.value=="NoData" || cell.value=="null")
             {
                 $td.html("<div class='align_center'></div>")
             }
             else
             {
                 $td.html("<div class='align_center'>"+cell.value+"</div>")
             }
         }
     });

     //List of table IDs to add icon
     var tableIDs = ["Mytable1", "Mytable2"];
     for (i=0;i<tableIDs.length;i++) {
         var sh = mvc.Components.get(tableIDs[i]);
         if(typeof(sh)!="undefined") {
             sh.getVisualization(function(tableView) {
                 // Add custom cell renderer and force re-render
                // Point-A
                 tableView.table.addCellRenderer(new CustomRangeRenderer());
                 tableView.table.render();
                 // Point-B
             });
         }
     }     
 });

My code is able to execute properly in Chrome.
While running in Firefox it reaches Point-A and Point-B but not to Point-C or Point-D. Any idea what can be wrong or any workaround.
While in Firefox also the issue is intermittent, at some random time out of two tables any one loads as well, but not all the time. Anyone have any idea why TableCellRenderer does not work in firefox sometimes?

Labels (2)
0 Karma
1 Solution

VatsalJagani
SplunkTrust
SplunkTrust

The issue is because JS loads before the dashboard. I found a workaround as follows.

Add one line at the end of your JS.

  ...........
                  tableView.table.render();
                  // Point-B
              });
          }
      }
      setToken("wait_for_js_to_load", " ");
  });

Prepend this token in all the table queries which have custom cell renderer. Ex.

$wait_for_js_to_load$ index=main | stats count by sourcetype

I found this issue in Splunk 8.0.1.

Hope this helps other people having same issue.

View solution in original post

niketn
Legend

@VatsalJagani this has been a bug in Splunk Table Cell render extension since Splunk 6.6 and above. Please refer to the previous question with a workaround with setTimeout to add a delay before table is rendered().

https://answers.splunk.com/answers/614788/splunk-dashboard-examples-table-row-highlighting-b.html?ch...

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

VatsalJagani
SplunkTrust
SplunkTrust

The issue is because JS loads before the dashboard. I found a workaround as follows.

Add one line at the end of your JS.

  ...........
                  tableView.table.render();
                  // Point-B
              });
          }
      }
      setToken("wait_for_js_to_load", " ");
  });

Prepend this token in all the table queries which have custom cell renderer. Ex.

$wait_for_js_to_load$ index=main | stats count by sourcetype

I found this issue in Splunk 8.0.1.

Hope this helps other people having same issue.

sreichel
Engager

This worked great for me. I found that I needed to use the "submitted" rather than "default" instance.

let sub_tokens = mvc.Components.getInstance("submitted");
...
sub_tokens.set("js_ready", " ");
0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...