<?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: How to expand and collapse table rows using javascript? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-expand-and-collapse-table-rows-using-javascript/m-p/333655#M21641</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/187810"&gt;@rijinc&lt;/a&gt; ,&lt;/P&gt;

&lt;P&gt;In you simple XML dashboard use this code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;dashboard script="expandRow.js"&amp;gt;
    ....
      &amp;lt;row&amp;gt;
        &amp;lt;panel&amp;gt;
          &amp;lt;table id="myTable"&amp;gt;
            &amp;lt;search id="mySearch"&amp;gt;
              &amp;lt;query&amp;gt;
                |loadjob savedsearch=admin:applist:apptest
              &amp;lt;/query&amp;gt;
            &amp;lt;/search&amp;gt;
            &amp;lt;fields&amp;gt;Name, Age, Hobby, Status&amp;lt;/fields&amp;gt;
          &amp;lt;/table&amp;gt;
        &amp;lt;/panel&amp;gt;
      &amp;lt;/row&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Place  &lt;CODE&gt;expandRow.js&lt;/CODE&gt; file into &lt;CODE&gt;$SPLUNK_HOME/etc/apps/&amp;lt;your_app&amp;gt;/appserver/static&lt;/CODE&gt; dir with this code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    'splunkjs/mvc/tableview',
    'splunkjs/mvc/postprocessmanager',
    'splunkjs/mvc',
    'underscore',
    'splunkjs/mvc/simplexml/ready!'],function(
    TableView,
    PostProcessManager,
    mvc,
    _
    ){
    var EventSearchBasedRowExpansionRenderer = TableView.BaseRowExpansionRenderer.extend({
        initialize: function(args) {

            this._postProcessManager = new PostProcessManager({
                id: 'ApplicationUsed ',
                managerid: 'mySearch'
            });
            this._tableView = new TableView({
                id: 'drop_down_table',
                managerid: 'ApplicationUsed'
            });
        },
        canRender: function(rowData) {
            // always expand
            console.log("RowData: ", rowData);
            return true;
        },
        render: function($container, rowData) {
            // rowData contains information about the row that is expanded.  We can see the cells, fields, and values
            // We will find the Name cell to use its value
            var username = _(rowData.cells).find(function (cell) {
               return cell.field === 'Name';
            });
            //update the search with the Name that we are interested in
            this._postProcessManager.set({ search: 
                '| search Name="' + username.value + '" | table ApplicationUsed '
                 });
            // $container is the jquery object where we can put out content.
            // In this case we will render our table and add it to the $container
            $container.append(this._tableView.render().el);
        }
    });
    var tableElement = mvc.Components.getInstance("myTable");
    tableElement.getVisualization(function(tableView) {
        // Add custom cell renderer, the table will re-render automatically.
        tableView.addRowExpansionRenderer(new EventSearchBasedRowExpansionRenderer());
    });
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After that you can customize CSS for you dashboard to edit #drop_down_table params for better visualization.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 23:15:33 GMT</pubDate>
    <dc:creator>pkarpushin</dc:creator>
    <dc:date>2020-09-29T23:15:33Z</dc:date>
    <item>
      <title>How to expand and collapse table rows using javascript?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-expand-and-collapse-table-rows-using-javascript/m-p/333653#M21639</link>
      <description>&lt;P&gt;I have seen one example of expanding table row and chart is displayed . I am not much familiar with javascript code&lt;/P&gt;

&lt;P&gt;My table currently has these values :&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/4512i251BCC9649AA30EE/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;Want these "application used"  row values to be displayed in an expanded row . &lt;/P&gt;

&lt;P&gt;The reason is because currently in a table view in Splunk dashboard there are more than 100 rows and even after displaying 5 rows in a table due to such values of more than 500 strings scrolling becomes tedious .&lt;/P&gt;

&lt;P&gt;Is it possible to do a table row expand of this column so that while expanding the values from application used field get displayed.&lt;/P&gt;

&lt;P&gt;My Splunk query is :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|loadjob savedsearch=admin:applist:apptest | table Name Age Hobby ApplicationUsed Status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any help would be very much useful is it possible  to do such a view ?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 14:08:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-expand-and-collapse-table-rows-using-javascript/m-p/333653#M21639</guid>
      <dc:creator>rijinc</dc:creator>
      <dc:date>2018-03-07T14:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to expand and collapse table rows using javascript?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-expand-and-collapse-table-rows-using-javascript/m-p/333654#M21640</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;Any help or inputs ?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Mar 2018 03:02:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-expand-and-collapse-table-rows-using-javascript/m-p/333654#M21640</guid>
      <dc:creator>rijinc</dc:creator>
      <dc:date>2018-03-08T03:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to expand and collapse table rows using javascript?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-expand-and-collapse-table-rows-using-javascript/m-p/333655#M21641</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/187810"&gt;@rijinc&lt;/a&gt; ,&lt;/P&gt;

&lt;P&gt;In you simple XML dashboard use this code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;dashboard script="expandRow.js"&amp;gt;
    ....
      &amp;lt;row&amp;gt;
        &amp;lt;panel&amp;gt;
          &amp;lt;table id="myTable"&amp;gt;
            &amp;lt;search id="mySearch"&amp;gt;
              &amp;lt;query&amp;gt;
                |loadjob savedsearch=admin:applist:apptest
              &amp;lt;/query&amp;gt;
            &amp;lt;/search&amp;gt;
            &amp;lt;fields&amp;gt;Name, Age, Hobby, Status&amp;lt;/fields&amp;gt;
          &amp;lt;/table&amp;gt;
        &amp;lt;/panel&amp;gt;
      &amp;lt;/row&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Place  &lt;CODE&gt;expandRow.js&lt;/CODE&gt; file into &lt;CODE&gt;$SPLUNK_HOME/etc/apps/&amp;lt;your_app&amp;gt;/appserver/static&lt;/CODE&gt; dir with this code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    'splunkjs/mvc/tableview',
    'splunkjs/mvc/postprocessmanager',
    'splunkjs/mvc',
    'underscore',
    'splunkjs/mvc/simplexml/ready!'],function(
    TableView,
    PostProcessManager,
    mvc,
    _
    ){
    var EventSearchBasedRowExpansionRenderer = TableView.BaseRowExpansionRenderer.extend({
        initialize: function(args) {

            this._postProcessManager = new PostProcessManager({
                id: 'ApplicationUsed ',
                managerid: 'mySearch'
            });
            this._tableView = new TableView({
                id: 'drop_down_table',
                managerid: 'ApplicationUsed'
            });
        },
        canRender: function(rowData) {
            // always expand
            console.log("RowData: ", rowData);
            return true;
        },
        render: function($container, rowData) {
            // rowData contains information about the row that is expanded.  We can see the cells, fields, and values
            // We will find the Name cell to use its value
            var username = _(rowData.cells).find(function (cell) {
               return cell.field === 'Name';
            });
            //update the search with the Name that we are interested in
            this._postProcessManager.set({ search: 
                '| search Name="' + username.value + '" | table ApplicationUsed '
                 });
            // $container is the jquery object where we can put out content.
            // In this case we will render our table and add it to the $container
            $container.append(this._tableView.render().el);
        }
    });
    var tableElement = mvc.Components.getInstance("myTable");
    tableElement.getVisualization(function(tableView) {
        // Add custom cell renderer, the table will re-render automatically.
        tableView.addRowExpansionRenderer(new EventSearchBasedRowExpansionRenderer());
    });
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After that you can customize CSS for you dashboard to edit #drop_down_table params for better visualization.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:15:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-expand-and-collapse-table-rows-using-javascript/m-p/333655#M21641</guid>
      <dc:creator>pkarpushin</dc:creator>
      <dc:date>2020-09-29T23:15:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to expand and collapse table rows using javascript?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-expand-and-collapse-table-rows-using-javascript/m-p/333656#M21642</link>
      <description>&lt;P&gt;It works well. But I used get the value at the specific location.&lt;BR /&gt;
       this._postProcessManager.set({ search: '| search Members=' + rowData.values[1] + ' | table Group '});&lt;/P&gt;

&lt;P&gt;So I don't use the search the cell field name.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 05:01:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-expand-and-collapse-table-rows-using-javascript/m-p/333656#M21642</guid>
      <dc:creator>louismai</dc:creator>
      <dc:date>2019-09-12T05:01:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to expand and collapse table rows using javascript?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-expand-and-collapse-table-rows-using-javascript/m-p/517812#M34704</link>
      <description>&lt;UL&gt;&lt;LI&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/114768"&gt;@pkarpushin&lt;/a&gt;&amp;nbsp;I have a similar use case but I need the two-level of row expansion, The first expansion is on main row and the second expansion is on the expanded row.&amp;nbsp; Is this possible? Please assist!&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Thu, 03 Sep 2020 19:58:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-expand-and-collapse-table-rows-using-javascript/m-p/517812#M34704</guid>
      <dc:creator>iamkilarunaresh</dc:creator>
      <dc:date>2020-09-03T19:58:31Z</dc:date>
    </item>
  </channel>
</rss>

