<?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 Access Row Fields in BaseCellRenderer in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Access-Row-Fields-in-BaseCellRenderer/m-p/277299#M17578</link>
    <description>&lt;P&gt;I am working with a custom HTML dashboard. I see how to use the TableView and the BaseCellRenderer together to customize the contents of a given cell in the table. However, when the BaseCellRenderer is called, it appears that I can only access the value of that field. Is there a way that I can reference the values of all the fields in that rows data?&lt;/P&gt;

&lt;P&gt;Here is what I'm trying to accomplish...&lt;/P&gt;

&lt;P&gt;I have a table displaying three columns of data. I want to add an action to the end of the row that when clicked, will grab the values of those three data columns and push those into a KV Store. I created a dummy field in my search (eval Action=1) so that the table renders an additional column for me to override with the BaseCellRenderer. But the only data I can see in that function is the value of the Action field which is 1. I need to know the values of the 3 other fields of that row.&lt;/P&gt;</description>
    <pubDate>Thu, 21 Jul 2016 15:55:18 GMT</pubDate>
    <dc:creator>tkreiner</dc:creator>
    <dc:date>2016-07-21T15:55:18Z</dc:date>
    <item>
      <title>Access Row Fields in BaseCellRenderer</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Access-Row-Fields-in-BaseCellRenderer/m-p/277299#M17578</link>
      <description>&lt;P&gt;I am working with a custom HTML dashboard. I see how to use the TableView and the BaseCellRenderer together to customize the contents of a given cell in the table. However, when the BaseCellRenderer is called, it appears that I can only access the value of that field. Is there a way that I can reference the values of all the fields in that rows data?&lt;/P&gt;

&lt;P&gt;Here is what I'm trying to accomplish...&lt;/P&gt;

&lt;P&gt;I have a table displaying three columns of data. I want to add an action to the end of the row that when clicked, will grab the values of those three data columns and push those into a KV Store. I created a dummy field in my search (eval Action=1) so that the table renders an additional column for me to override with the BaseCellRenderer. But the only data I can see in that function is the value of the Action field which is 1. I need to know the values of the 3 other fields of that row.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2016 15:55:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Access-Row-Fields-in-BaseCellRenderer/m-p/277299#M17578</guid>
      <dc:creator>tkreiner</dc:creator>
      <dc:date>2016-07-21T15:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: Access Row Fields in BaseCellRenderer</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Access-Row-Fields-in-BaseCellRenderer/m-p/277300#M17579</link>
      <description>&lt;P&gt;May be easier to populate the hidden field with concatenated values in the search that populates the table. Or create a hidden search that gets values from all three cells ($row.&amp;lt;&amp;gt;$) and call &lt;CODE&gt;outputlookup&lt;/CODE&gt; to update &lt;CODE&gt;kvstore&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2016 22:19:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Access-Row-Fields-in-BaseCellRenderer/m-p/277300#M17579</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-07-21T22:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Access Row Fields in BaseCellRenderer</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Access-Row-Fields-in-BaseCellRenderer/m-p/277301#M17580</link>
      <description>&lt;P&gt;Thanks sundareshr. I had thought about the concatenated field. It's an ugly way of doing it, but it is possible. I may give that a try. For now, I decided to go the route of using a RowExpansionRenderer and creating an action underneath the row. It adds an extra click, but it does work.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2016 17:40:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Access-Row-Fields-in-BaseCellRenderer/m-p/277301#M17580</guid>
      <dc:creator>tkreiner</dc:creator>
      <dc:date>2016-07-22T17:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: Access Row Fields in BaseCellRenderer</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Access-Row-Fields-in-BaseCellRenderer/m-p/277302#M17581</link>
      <description>&lt;P&gt;I found an answer to this question from a colleague. The BaseCellRenderer is called sequentially for each column of the output. Therefore, it will touch each cell leading up to the last column where I want to create my action link. Because of this, you can write script for each column to capture that column's value and hold it in a temporary JavaScript variable. When you render the last column, you can pull from the JavaScript variables to the data you need from the record to create the link.&lt;/P&gt;

&lt;P&gt;In my example, I was working with ps data from Linux and I needed to capture the HOST, COMMAND and ARGUMENTS fields. In my JavaScript, I first created three global variables:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var rowHost;
var rowCommand;
var rowArguments;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then my BaseCellRenderer definition looks something like the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;            // Use the BaseCellRenderer class to create a custom table cell renderer
            var AddMonitorRenderer = TableView.BaseCellRenderer.extend({ 
                canRender: function(cellData) {
                    return true;
                },

                // This render function only works when canRender returns "true"
                render: function($td, cellData) {
                    switch(cellData.field.toUpperCase())
                    {
                        case "HOST":
                            rowHost = cellData.value;
                            break;
                        case "COMMAND":
                            rowCommand = cellData.value;
                            break;
                        case "ARGUMENTS":
                            rowArguments = cellData.value;
                            break;
                        default:
                    }

                    if(cellData.field == "Action") {
                        $td.html('&amp;lt;div align="right"&amp;gt;&amp;lt;a href="#" onclick="addMonitor(\'' + escapeJSValue(rowHost) + '\',\'' 
                        + escapeJSValue(rowCommand) + '\',\'' 
                        + escapeJSValue(rowArguments) + '\')"&amp;gt;Add to Monitor&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;');
                    }
                    else {
                        $td.html(cellData.value);
                    }
                }
            });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This does a couple of things:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;The &lt;CODE&gt;canRender&lt;/CODE&gt; function always returns a value of true. This way, the renderer class will fire for each column of the result set.&lt;/LI&gt;
&lt;LI&gt;In the &lt;CODE&gt;render&lt;/CODE&gt; function, I test to see which field the renderer is currently running for (HOST, COMMAND, ARGUMENTS) and then I store that column's value in the appropriate global variable.&lt;/LI&gt;
&lt;LI&gt;In the final &lt;CODE&gt;if&lt;/CODE&gt; statement, if I am in my Action column (this was a dummy value that I added to my search criteria using &lt;CODE&gt;| eval Action = 1&lt;/CODE&gt;), then I display a link to my &lt;CODE&gt;addMonitor()&lt;/CODE&gt; function. (NOTE: The &lt;CODE&gt;escapeJSValue()&lt;/CODE&gt; function is a custom function I have in another part of my code.) If I am not in my Action column, then simply display that column's field value.&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;I added this cell renderer to my TableView and rendered the table and my action appears and works correctly.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 13:35:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Access-Row-Fields-in-BaseCellRenderer/m-p/277302#M17581</guid>
      <dc:creator>tkreiner</dc:creator>
      <dc:date>2016-07-25T13:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: Access Row Fields in BaseCellRenderer</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Access-Row-Fields-in-BaseCellRenderer/m-p/277303#M17582</link>
      <description>&lt;P&gt;Hi, i would like to do something very similar. I would like to add checkboxes to every row and then have a button that does a mass update to the kv store. Would you mind sharing the addMonitor function? &lt;/P&gt;</description>
      <pubDate>Thu, 26 Apr 2018 14:16:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Access-Row-Fields-in-BaseCellRenderer/m-p/277303#M17582</guid>
      <dc:creator>chris</dc:creator>
      <dc:date>2018-04-26T14:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: Access Row Fields in BaseCellRenderer</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Access-Row-Fields-in-BaseCellRenderer/m-p/277304#M17583</link>
      <description>&lt;P&gt;This saved me lots of work and headache, thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 17:18:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Access-Row-Fields-in-BaseCellRenderer/m-p/277304#M17583</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2018-06-19T17:18:09Z</dc:date>
    </item>
    <item>
      <title>Re: Access Row Fields in BaseCellRenderer</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Access-Row-Fields-in-BaseCellRenderer/m-p/558084#M38819</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/88"&gt;@chris&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Were you able to add checkbox in every row and select all checkbox in table? I am looking for something like that? Would you mind sharing how you did that?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 05:27:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Access-Row-Fields-in-BaseCellRenderer/m-p/558084#M38819</guid>
      <dc:creator>bijolianabhi</dc:creator>
      <dc:date>2021-07-02T05:27:10Z</dc:date>
    </item>
  </channel>
</rss>

