<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Table drilldown: Disable link conditionally in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Table-drilldown-Disable-link-conditionally/m-p/258253#M77362</link>
    <description>&lt;P&gt;Hi jeffland, thank you for your response.&lt;/P&gt;

&lt;P&gt;I changed 'cell.field' and 'cell.value' to those you mentioned, but I do not see .preventDefault() working.&lt;BR /&gt;
Even if I try the simplest thing that I can:&lt;BR /&gt;
    var table1 = mvc.Components.get('table1');&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;table1.on('click', function(cell) {
    cell.preventDefault(); // When I place a breakpoint here and click on table1, the drilldown takes place even before this line executes.
    var col = cell.data['click.name2'];
    var val = cell.data['click.value2'];
});
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 25 Jan 2017 02:37:36 GMT</pubDate>
    <dc:creator>enexwhy</dc:creator>
    <dc:date>2017-01-25T02:37:36Z</dc:date>
    <item>
      <title>Table drilldown: Disable link conditionally</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-drilldown-Disable-link-conditionally/m-p/258251#M77360</link>
      <description>&lt;P&gt;I have a table with cell drilldown enabled.&lt;BR /&gt;
However, in certain conditions I want to disable the drilldown, for example:&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2382i01AA340D4816800B/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I want the drilldown to be enabled for 'pass' but not for 'fail'.&lt;BR /&gt;
I have some code in my .js file but it does not work. I am not very familiar with JavaScript.&lt;/P&gt;

&lt;P&gt;Anyway this is what I want to achieve:&lt;BR /&gt;
// Disables cells conditionally&lt;BR /&gt;
var table1 = mvc.Components.get('table1');&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;table1.on('click', function(cell) {
    console.log(cell.field);
    console.log(cell.value); // I can get cell.field, but not cell.value -- how can I get cell.value?

    if (cell.field == 'status' &amp;amp;&amp;amp; cell.value == 'fail') {
        cell.preventDefault(); // Disable the drilldown here
    }
});
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Jan 2017 08:45:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-drilldown-Disable-link-conditionally/m-p/258251#M77360</guid>
      <dc:creator>enexwhy</dc:creator>
      <dc:date>2017-01-24T08:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: Table drilldown: Disable link conditionally</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-drilldown-Disable-link-conditionally/m-p/258252#M77361</link>
      <description>&lt;P&gt;You could use the &lt;CODE&gt;cell.data&lt;/CODE&gt; object to get the required info. It contains everything also available for the Simple XML drilldown actions, such as &lt;CODE&gt;click.name2&lt;/CODE&gt; and so on. You'll want these two:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;cell.data["click.name2"] // name of the clicked cell
cell.data["click.value2"] // value of the clicked cell
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;By the way, if you want to learn and understand what's happening, I recommend using your browsers developer tools, namely the debugger, to set breakpoints and check which objects are available and which info they contain. For example, you could set a breakpoint on the first line of the anonymous function you call &lt;CODE&gt;on('click'&lt;/CODE&gt; and check out the &lt;CODE&gt;cell&lt;/CODE&gt; object. In Chrome and Firefox, you press F12 and go to the Debugger tab. In the list of sources, look for your js file.&lt;BR /&gt;
If you're on 6.5 and above, you'll need to insert a &lt;CODE&gt;debugger;&lt;/CODE&gt; statement in your js file to make it appear in the list of sources, see &lt;A href="https://answers.splunk.com/answers/456860/why-are-javascript-files-not-loading-after-update-1.html"&gt;here&lt;/A&gt; (answer by rjthibod) for source.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 11:57:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-drilldown-Disable-link-conditionally/m-p/258252#M77361</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2017-01-24T11:57:28Z</dc:date>
    </item>
    <item>
      <title>Re: Table drilldown: Disable link conditionally</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-drilldown-Disable-link-conditionally/m-p/258253#M77362</link>
      <description>&lt;P&gt;Hi jeffland, thank you for your response.&lt;/P&gt;

&lt;P&gt;I changed 'cell.field' and 'cell.value' to those you mentioned, but I do not see .preventDefault() working.&lt;BR /&gt;
Even if I try the simplest thing that I can:&lt;BR /&gt;
    var table1 = mvc.Components.get('table1');&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;table1.on('click', function(cell) {
    cell.preventDefault(); // When I place a breakpoint here and click on table1, the drilldown takes place even before this line executes.
    var col = cell.data['click.name2'];
    var val = cell.data['click.value2'];
});
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Jan 2017 02:37:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-drilldown-Disable-link-conditionally/m-p/258253#M77362</guid>
      <dc:creator>enexwhy</dc:creator>
      <dc:date>2017-01-25T02:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: Table drilldown: Disable link conditionally</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-drilldown-Disable-link-conditionally/m-p/258254#M77363</link>
      <description>&lt;P&gt;That has to be caused by something else you do on your dashboard. You could start from a minimal example like this Simple XML:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="preventDrilldown.js"&amp;gt;
  &amp;lt;label&amp;gt;Preventing Drilldown&amp;lt;/label&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table id="table"&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=_internal | stats count by group&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-15m&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and this javascript:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    "splunkjs/mvc",
    "splunkjs/mvc/simplexml/ready!"
], function (mvc) {
    var table = mvc.Components.get("table");
    table.on("click", function (cell) {
        cell.preventDefault();
    });
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This has to work. From there, add features you have on your original dashboard until you hit the culprit. Unfortunately, that's all I can do from here &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 15:30:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-drilldown-Disable-link-conditionally/m-p/258254#M77363</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2017-01-25T15:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: Table drilldown: Disable link conditionally</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-drilldown-Disable-link-conditionally/m-p/258255#M77364</link>
      <description>&lt;P&gt;I figured it out. I had to remove all the drilldowns I defined in the XML, and redefine them in the .js file. I was thinking that .preventDefault() would stop those from happening but then I realized that 'default' means the default drilldown that produces the search query based on the cell you click on.&lt;/P&gt;

&lt;P&gt;Thanks again for your responses.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2017 04:25:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-drilldown-Disable-link-conditionally/m-p/258255#M77364</guid>
      <dc:creator>enexwhy</dc:creator>
      <dc:date>2017-01-26T04:25:35Z</dc:date>
    </item>
  </channel>
</rss>

