<?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: TableView in JavaScript Prevent Sorting or Capture Event in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/TableView-in-JavaScript-Prevent-Sorting-or-Capture-Event/m-p/395868#M25922</link>
    <description>&lt;P&gt;You answered #1 thank you it did the trick. &lt;BR /&gt;
Any suggestions on #2? &lt;/P&gt;</description>
    <pubDate>Sun, 13 Jan 2019 14:08:57 GMT</pubDate>
    <dc:creator>jrouse025</dc:creator>
    <dc:date>2019-01-13T14:08:57Z</dc:date>
    <item>
      <title>TableView in JavaScript Prevent Sorting or Capture Event</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/TableView-in-JavaScript-Prevent-Sorting-or-Capture-Event/m-p/395866#M25920</link>
      <description>&lt;P&gt;I am using SplunkJS framework to create a new TableView and how do you do the following:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Turn off sorting (yes prevent the user from changing the sort order)&lt;/LI&gt;
&lt;LI&gt;Attach to table event that would allow me to capture and event such as  mytableview.on('sort', function (columnName, sortdirection){})&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Thu, 10 Jan 2019 16:32:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/TableView-in-JavaScript-Prevent-Sorting-or-Capture-Event/m-p/395866#M25920</guid>
      <dc:creator>jrouse025</dc:creator>
      <dc:date>2019-01-10T16:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: TableView in JavaScript Prevent Sorting or Capture Event</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/TableView-in-JavaScript-Prevent-Sorting-or-Capture-Event/m-p/395867#M25921</link>
      <description>&lt;P&gt;@jrouse025 , This would be possible through SimpleXML JS Extension. You would need to remove &lt;CODE&gt;sorts&lt;/CODE&gt; class and &lt;CODE&gt;data-sort-key&lt;/CODE&gt; attributes from the Table header to remove sorting.&lt;/P&gt;

&lt;P&gt;Try the following run Dashboard Example which has table with id &lt;CODE&gt;tableWithoutSort&lt;/CODE&gt; for removing table sorting.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="table_disable_sort.js"&amp;gt;
  &amp;lt;label&amp;gt;Remove Table Sort&amp;lt;/label&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table id="tableWithoutSort"&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=_internal sourcetype=splunkd
| stats count by log_level&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;20&amp;lt;/option&amp;gt;
        &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="percentagesRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="totalsRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="wrap"&amp;gt;true&amp;lt;/option&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;Following is the required JavaScript code for &lt;CODE&gt;table_disable_sort.js&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; require([
     'underscore',
     'jquery',
     'splunkjs/mvc',
     'splunkjs/mvc/tableview',
     'splunkjs/mvc/simplexml/ready!'
 ], function (_, $, mvc, TableView) {
    mvc.Components.get('tableWithoutSort').getVisualization(function(tableView) {
        tableView.on('rendered', function() {
            setTimeout(function(){
                $("#tableWithoutSort table thead th").removeClass("sorts").removeAttr("data-sort-key");
            },100);
        }); 
    }); 
 });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: &lt;CODE&gt;setTimeout()&lt;/CODE&gt; after table &lt;CODE&gt;render()&lt;/CODE&gt; function is required in Splunk 6.5 higher versions as already reported in other questions on Splunk Answers. Please try out and confirm!&lt;/P&gt;</description>
      <pubDate>Sat, 12 Jan 2019 18:25:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/TableView-in-JavaScript-Prevent-Sorting-or-Capture-Event/m-p/395867#M25921</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-01-12T18:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: TableView in JavaScript Prevent Sorting or Capture Event</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/TableView-in-JavaScript-Prevent-Sorting-or-Capture-Event/m-p/395868#M25922</link>
      <description>&lt;P&gt;You answered #1 thank you it did the trick. &lt;BR /&gt;
Any suggestions on #2? &lt;/P&gt;</description>
      <pubDate>Sun, 13 Jan 2019 14:08:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/TableView-in-JavaScript-Prevent-Sorting-or-Capture-Event/m-p/395868#M25922</guid>
      <dc:creator>jrouse025</dc:creator>
      <dc:date>2019-01-13T14:08:57Z</dc:date>
    </item>
    <item>
      <title>Re: TableView in JavaScript Prevent Sorting or Capture Event</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/TableView-in-JavaScript-Prevent-Sorting-or-Capture-Event/m-p/395869#M25923</link>
      <description>&lt;P&gt;I am sorry I missed #2... could you elaborate on the requirement? What is the expected behavior?&lt;/P&gt;</description>
      <pubDate>Sun, 13 Jan 2019 16:10:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/TableView-in-JavaScript-Prevent-Sorting-or-Capture-Event/m-p/395869#M25923</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-01-13T16:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: TableView in JavaScript Prevent Sorting or Capture Event</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/TableView-in-JavaScript-Prevent-Sorting-or-Capture-Event/m-p/395870#M25924</link>
      <description>&lt;P&gt;Requirement: If we were to keep the sorting capabilities on the columns we would need to subscribe to table 'sort' or 'sorting' event.&lt;BR /&gt;
Let me know if you need more information.&lt;/P&gt;

&lt;P&gt;Regards.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jan 2019 12:54:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/TableView-in-JavaScript-Prevent-Sorting-or-Capture-Event/m-p/395870#M25924</guid>
      <dc:creator>jrouse025</dc:creator>
      <dc:date>2019-01-14T12:54:05Z</dc:date>
    </item>
  </channel>
</rss>

