Dashboards & Visualizations

Can I make two mvc.Components.get?

josefa123
Explorer
 mvc.Components.get('highlight').getVisualization(function(tableView) {
        // Add custom cell renderer
        tableView.table.addCellRenderer(new RangeMapIconRenderer());
        tableView.table.addCellRenderer(new CustomRangeRenderer());
        tableView.on('rendered', function() {
            // Apply class of the cells to the parent row in order to color the whole row
            tableView.$el.find('td.range-cell').each(function() {
                $(this).parents('tr').addClass(this.className);
            });
        });
        // Force the table to re-render
        tableView.table.render();
    });




 mvc.Components.get('highlight2').getVisualization(function(tableView) {
        // Add custom cell renderer
        tableView.table.addCellRenderer(new RangeMapIconRenderer());
        tableView.table.addCellRenderer(new CustomRangeRenderer());
        tableView.on('rendered', function() {
            // Apply class of the cells to the parent row in order to color the whole row
            tableView.$el.find('td.range-cell').each(function() {
                $(this).parents('tr').addClass(this.className);
            });
        });
        // Force the table to re-render
        tableView.table.render();
    });

to prevent adding multiple js in one dashboard? and also can I ask what framework is mvc.Components.get? is it backbone or the splunk itself? Thanks

Tags (2)
0 Karma
1 Solution

jeffland
SplunkTrust
SplunkTrust

Yes, you can add as much javascript to one file as you see fit (although it may be a good idea to split them if the code they contain do different jobs). You can also re-use the same .js in multiple dashboards if they require the same code.

As I just replied to your other question, I believe the mvc.Components.get() is from backbone.js.

View solution in original post

jeffland
SplunkTrust
SplunkTrust

Yes, you can add as much javascript to one file as you see fit (although it may be a good idea to split them if the code they contain do different jobs). You can also re-use the same .js in multiple dashboards if they require the same code.

As I just replied to your other question, I believe the mvc.Components.get() is from backbone.js.

Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...