Quantcast
Channel: Questions in topic: "splunk-enterprise"
Viewing all articles
Browse latest Browse all 47296

Is there a way to hardcode a dashboard drilldown link in Javascript?

$
0
0
Hola! I ran in to a minor "drilldown" problem with one of my dashboards once we upgraded from 6.0.x to 6.2.5, and am looking for some insight on possible fixes. **High Level:** We use a custom Splunk command to go out and fetch some file and download the PDF right from the view. What started happening in our dev environment after the upgrade is when we click "PDF Link" it would not only fetch the file as expected, but it would drilldown to the search app. Before we could actually click the link and it would stay on the dashboard view even while cell drilldown is enabled. The reason we have cell drilldown turned on is because there is another cell on the same row that allows users to go to another dashboard. **Potential Solution:** There is a nice solution here to drill down to absolute URL using clickvalue: http://answers.splunk.com/answers/85517/drill-down-to-absolute-url-using-clickvalue This is nice, because what I think we could do is use a similar .js file to turn the drilldown cell in to a link that redirects users to the page all while providing the functionality to pass values like any other dashboard. **Problem:** Is there a way to hardcode the dashboard link in to the JS file, so that if we turn off cell drill-down we can still use the same functionality? **Code Samples:** *Dashboard Simple XML:*
-30d@dnow
Your Search Results:index=contract_ereceipt_summary source=contract_ereceipt_summary $field1$ $field2$ $field3$ | eval pdfDownloadUrl = if( isnull(PID_OUT), "One or more required fields needed to download the PDF are not available.", eReceiptUrlBase + "?bp_context_id=" + bp_context_id + "&TPCode=" + TPCode + "&PID_OUT=" + PID_OUT) | table fields | sort - _time | convert ctime(_time) |`ctg_common_header_rename` | rename pdfDownloadUrl as "Download PDF"
*New JS File to create Link:* require([ 'underscore', 'jquery', 'splunkjs/mvc', 'splunkjs/mvc/tableview', 'splunkjs/mvc/simplexml/ready!' ], function(_, $, mvc, TableView) { var CustomLinkRenderer = TableView.BaseCellRenderer.extend({ canRender: function(cell) { return cell.field === 'Re-Submit'; }, render: function($td, cell) { var link = cell.value; var a = $('').attr("href", link).text("Re-Submit e-Receipt Here"); $td.addClass('table-link').empty().append(a); a.click(function(e) { e.preventDefault(); // for current window: //window.location = $(e.currentTarget).attr('href'); // or for popup: window.open($(e.currentTarget).attr('href')); }); } }); // Get the table view by id mvc.Components.get('ereceipt_results').getVisualization(function(tableView){ // Register custom cell renderer tableView.table.addCellRenderer(new CustomLinkRenderer()); // Force the table to re-render tableView.table.render(); }); }); Let me know if I can provide you with any other details. Thanks in Advance!

Viewing all articles
Browse latest Browse all 47296

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>