Dashboards & Visualizations

TableView.on('rendered') stop working after a certain number of tables

denzelchung
Path Finder

I have a dashboard with 1 table and the following code works. It adds a CSS class to the tag as expected.

However, if I add more tables on the same dashboard, the code works on certain refreshes and not on others. I tried playing around with the timeout value and didn't manage to find a solution. With 1-3 tables in the dashboard, it works on the times I tried, but 4 or more tables will cause an erratic behavior.

 mvc.Components.get('table1').getVisualization(function(tableView) {
    setTimeout(function() {
        tableView.on('rendered', function() {
            // Populate dictionary with values from table
            var tableRows = tableView.$el.find('tbody').children();
            $.each(tableRows, function(index, row) {
                var children = $(row).children();
                var key = children.eq(0).text();
                var value = $.trim(children.eq(1).text());

                if (value == "0") {
                    $(row).addClass("range-down");
                }
                else {
                    $(row).addClass("range-ok");
                }
            });

            // Update table display
            tableView.render();
        })
    }, 100);
});
Tags (3)
0 Karma

denzelchung
Path Finder

I used the cell renderer method and it also faces the same problem.

    var CustomCellRenderer = TableView.BaseCellRenderer.extend({
        canRender: function(cell) {
            // Enable this custom cell renderer for the time field
            return _(['time']).contains(cell.field);
},
        render: function($td, cell) {
            var value = cell.value;

            if (value == "0") {
                $td.addClass('range-cell').addClass("range-down");
            }
            else {
                $td.addClass('range-cell').addClass("range-ok");
            }

            $td.text(value);
        }
    });
0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...