<?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 can i re-use Java scripts form one table to another tables in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-i-re-use-Java-scripts-form-one-table-to-another-tables/m-p/414870#M27273</link>
    <description>&lt;P&gt;Welcome &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Jan 2019 17:08:03 GMT</pubDate>
    <dc:creator>vnravikumar</dc:creator>
    <dc:date>2019-01-21T17:08:03Z</dc:date>
    <item>
      <title>How can i re-use Java scripts form one table to another tables</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-i-re-use-Java-scripts-form-one-table-to-another-tables/m-p/414861#M27264</link>
      <description>&lt;P&gt;@niketnilayn&lt;/P&gt;

&lt;P&gt;This is a great answer and thanks&lt;BR /&gt;
 &lt;A href="https://answers.splunk.com/answers/618930/how-can-i-get-the-table-cell-colorization-renderin-1.html" target="_blank"&gt;https://answers.splunk.com/answers/618930/how-can-i-get-the-table-cell-colorization-renderin-1.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I was wondering if you could tell me how to apply it to more then one table.&lt;BR /&gt;
I need to have 2 tables with different color needs, however my java script it not great at all.&lt;/P&gt;

&lt;P&gt;For example the first example is working fine&lt;/P&gt;

&lt;P&gt;I have copied the javascript and made a new one called table_cell_render_all_cells1.js, so i want the second table to refer to that one.&lt;/P&gt;

&lt;P&gt;First Table (Working)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;     &amp;lt;row&amp;gt;
        &amp;lt;panel depends="$alaysHideCSS$"&amp;gt;
          &amp;lt;html&amp;gt;
             &amp;lt;style&amp;gt;
               #highlight td {
                   background-color: #6DB7C6 !important;
               }
               */
               #highlight td.range-low {
                   color: #6DB7C6;
               }
               #highlight td.range-elevated {
                   background-color: #ffc57a !important;
                   font-weight: bold;
               }
               #highlight td.range-severe {
                   background-color: #d59392 !important;
                   font-weight: bold;
               }          
             &amp;lt;/style&amp;gt;
           &amp;lt;/html&amp;gt;
        &amp;lt;/panel&amp;gt;
        &amp;lt;panel&amp;gt;
         &amp;lt;title&amp;gt;NOK - Real Time (Count)&amp;lt;/title&amp;gt;
          &amp;lt;table id="highlight"&amp;gt;
            &amp;lt;search id="myTableSearch"&amp;gt;
              &amp;lt;query&amp;gt;| tstats summariesonly=true values(All_TPS_Logs.duration) AS Duration max(All_TPS_Logs.duration) AS All_TPS_Logs.duration FROM datamodel=TPS_V5 WHERE (nodename=All_TPS_Logs host=LUAS_2019_01_01 All_TPS_Logs.duration &amp;lt;= 1000000000000 All_TPS_Logs.duration &amp;gt;= -10000000 (All_TPS_Logs.user=* OR NOT All_TPS_Logs.user=*) All_TPS_Logs.operationIdentity="*") All_TPS_Logs.name =*** GROUPBY _time, All_TPS_Logs.fullyQualifiedMethod span=1s 
        | rename All_TPS_Logs.fullyQualifiedMethod as series 
        | rename All_TPS_Logs.duration as value 
        | table _time series value 
        | search (series=**murex**) 
        | lookup TPS_TAGS_HIGH_LEVEL Method#Class AS "series" OUTPUT TAG Threshold 
        | where value &amp;gt; Threshold 
        | fillnull Threshold 
        | fillnull TAG 
        | eval TAG=if(TAG=0,"PLEASE_ADD_TAG",TAG) 
         | search NOT TAG = "PLEASE_ADD_TAG"
    | timechart span=1h count(value) by TAG 
    | untable _time TAG value 
    | eval c_time=strftime(_time,"%F %T") 
    | xyseries TAG c_time value | rename TAG as _time&amp;lt;/query&amp;gt;
                &amp;lt;earliest&amp;gt;$time_token.earliest$&amp;lt;/earliest&amp;gt;
              &amp;lt;latest&amp;gt;$time_token.latest$&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;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However the second one is not - On the same page. I have changed a few things for example        &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;       &amp;lt;table id="highlight1"&amp;gt;
        &amp;lt;search id="myTableSearch1"&amp;gt;

-------------------





  &amp;lt;row&amp;gt;
        &amp;lt;panel depends="$alaysHideCSS$"&amp;gt;
          &amp;lt;html&amp;gt;
             &amp;lt;style&amp;gt;
               #highlight1 td {
                   background-color: #6DB7C6 !important;
               }
               */
               #highlight1 td.range-low {
                   color: #6DB7C6;
               }
               #highlight1 td.range-elevated {
                   background-color: #ffc57a !important;
                   font-weight: bold;
               }
               #highlight1 td.range-severe {
                   background-color: #d59392 !important;
                   font-weight: bold;
               }          
             &amp;lt;/style&amp;gt;
           &amp;lt;/html&amp;gt;
        &amp;lt;/panel&amp;gt;
        &amp;lt;panel&amp;gt;
         &amp;lt;title&amp;gt;OK - Real Time (Count)&amp;lt;/title&amp;gt;
          &amp;lt;table id="highlight1"&amp;gt;
            &amp;lt;search id="myTableSearch1"&amp;gt;
              &amp;lt;query&amp;gt;| tstats summariesonly=true values(All_TPS_Logs.duration) AS Duration max(All_TPS_Logs.duration) AS All_TPS_Logs.duration FROM datamodel=TPS_V5 WHERE (nodename=All_TPS_Logs host=LUAS_2019_01_01 All_TPS_Logs.duration &amp;lt;= 1000000000000 All_TPS_Logs.duration &amp;gt;= -10000000 (All_TPS_Logs.user=* OR NOT All_TPS_Logs.user=*) All_TPS_Logs.operationIdentity="*") All_TPS_Logs.name =*** GROUPBY _time, All_TPS_Logs.fullyQualifiedMethod span=1s 
        | rename All_TPS_Logs.fullyQualifiedMethod as series 
        | rename All_TPS_Logs.duration as value 
        | table _time series value 
        | search (series=**murex**) 
        | lookup TPS_TAGS_HIGH_LEVEL Method#Class AS "series" OUTPUT TAG Threshold 
        | where value &amp;gt; Threshold 
        | fillnull Threshold 
        | fillnull TAG 
        | eval TAG=if(TAG=0,"PLEASE_ADD_TAG",TAG) 
         | search NOT TAG = "PLEASE_ADD_TAG"
    | timechart span=1h count(value) by TAG 
    | untable _time TAG value 
    | eval c_time=strftime(_time,"%F %T") 
    | xyseries TAG c_time value | rename TAG as _time&amp;lt;/query&amp;gt;
                &amp;lt;earliest&amp;gt;$time_token.earliest$&amp;lt;/earliest&amp;gt;
              &amp;lt;latest&amp;gt;$time_token.latest$&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;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Seconds Java script&lt;BR /&gt;
I have changed one thing, myTableSearch1 as i reference this in my second table.&lt;BR /&gt;
var mySearch = splunkjs.mvc.Components.getInstance("myTableSearch1");&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
     "underscore",
     "jquery",
     "splunkjs/mvc",
     "splunkjs/mvc/searchmanager",
     "splunkjs/mvc/tableview",
     "splunkjs/mvc/simplexml/ready!"
 ], function(_, $, mvc, SearchManager, TableView) {

     var mySearch = splunkjs.mvc.Components.getInstance("myTableSearch1");
     var myResults = mySearch.data("results", {count:0});
     var allFields,filteredFields;
     myResults.on("data", function(){
         allFields=myResults.data().fields;
         filteredFields=allFields.filter(filterFields);
         console.log("Filtered Fields:",filteredFields);
     });
     function filterFields(field) {
         return field !== "_time";
     }
     // Row Coloring Example with custom, client-side range interpretation
     var CustomRangeRenderer = TableView.BaseCellRenderer.extend({
         canRender: function(cell) {
             // Enable this custom cell renderer for all fields except _time
             return _(filteredFields).contains(cell.field);
         },
         render: function($td, cell) {
             // Add a class to the cell based on the returned value
             var value = parseInt(cell.value);

             // Apply interpretation based on count of errors per _time for each field
             if(cell.field !== "_time"){
                 if (value &amp;gt;= 5) {
                     $td.addClass("range-cell").addClass("range-severe");
                 }
                 else if (value &amp;gt;= 1 &amp;amp;&amp;amp; value &amp;lt; 5) {
                     $td.addClass("range-cell").addClass("range-elevated");
                 }
                 else if (value &amp;lt; 1) {
                     $td.addClass("range-cell").addClass("range-low");
                 }
                 // Update the cell content
                 $td.text(value).addClass("numeric");
             }
         }
     });
     mvc.Components.get("highlight1").getVisualization(function(tableView) {
         // Add custom cell renderer, the table will re-render automatically.
         tableView.addCellRenderer(new CustomRangeRenderer());
     });

 });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;any help would be super and thanks&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:50:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-i-re-use-Java-scripts-form-one-table-to-another-tables/m-p/414861#M27264</guid>
      <dc:creator>robertlynch2020</dc:creator>
      <dc:date>2020-09-29T22:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: How can i re-use Java scripts form one table to another tables</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-i-re-use-Java-scripts-form-one-table-to-another-tables/m-p/414862#M27265</link>
      <description>&lt;P&gt;Hi @robertlynch2020&lt;/P&gt;

&lt;P&gt;Refer the following js and modify your js accordingly to apply for more than one table&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; require([
     'underscore',
     'jquery',
     'splunkjs/mvc',
     'splunkjs/mvc/tableview',
     'splunkjs/mvc/simplexml/ready!'
 ], function(_, $, mvc, TableView) {

     var CustomRangeRenderer = TableView.BaseCellRenderer.extend({
         canRender: function(cell) {
             return _(['Priority','Minumum','Percentage']).contains(cell.field);
         },
         render: function($td, cell) {
             var label = cell.value.split("|")[0];
             var val = cell.value.split("|")[1];

               if(val=="high" || val=="low" )
               {
                   $td.html("&amp;lt;div class='css_for_"+label+"_"+val+"'&amp;gt;"+label+"&amp;lt;/div&amp;gt;")
               }
               else
               {
                    $td.html("&amp;lt;div class='align_center'&amp;gt;"+label+"&amp;lt;/div&amp;gt;")
               }

         }
     });

     //List of table IDs to add icon
     var tableIDs = ["custom_table","custom_table1","custom_table3"];
     for (i=0;i&amp;lt;tableIDs.length;i++) {
         var sh = mvc.Components.get(tableIDs[i]);
         if(typeof(sh)!="undefined") {
             sh.getVisualization(function(tableView) {
                 // Add custom cell renderer and force re-render
                 tableView.table.addCellRenderer(new CustomRangeRenderer());
                 tableView.table.render();
             });
         }
     }    
 });
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 20 Jan 2019 12:47:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-i-re-use-Java-scripts-form-one-table-to-another-tables/m-p/414862#M27265</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-01-20T12:47:41Z</dc:date>
    </item>
    <item>
      <title>Re: How can i re-use Java scripts form one table to another tables</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-i-re-use-Java-scripts-form-one-table-to-another-tables/m-p/414863#M27266</link>
      <description>&lt;P&gt;@robertlynch2020&lt;/P&gt;

&lt;P&gt;Modify the following part&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;     mvc.Components.get("highlight1").getVisualization(function(tableView) {
          // Add custom cell renderer, the table will re-render automatically.
          tableView.addCellRenderer(new CustomRangeRenderer());
      });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;with&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;//List of table IDs to add icon
      var tableIDs = ["custom_table","custom_table1","custom_table3"];
      for (i=0;i&amp;lt;tableIDs.length;i++) {
          var sh = mvc.Components.get(tableIDs[i]);
          if(typeof(sh)!="undefined") {
              sh.getVisualization(function(tableView) {
                  // Add custom cell renderer and force re-render
                  tableView.table.addCellRenderer(new CustomRangeRenderer());
                  tableView.table.render();
              });
          }
      }    
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 20 Jan 2019 12:55:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-i-re-use-Java-scripts-form-one-table-to-another-tables/m-p/414863#M27266</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-01-20T12:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: How can i re-use Java scripts form one table to another tables</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-i-re-use-Java-scripts-form-one-table-to-another-tables/m-p/414864#M27267</link>
      <description>&lt;P&gt;Similarly, in css specify your table id accordingly for the second table&lt;/P&gt;</description>
      <pubDate>Sun, 20 Jan 2019 13:03:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-i-re-use-Java-scripts-form-one-table-to-another-tables/m-p/414864#M27267</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-01-20T13:03:01Z</dc:date>
    </item>
    <item>
      <title>Re: How can i re-use Java scripts form one table to another tables</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-i-re-use-Java-scripts-form-one-table-to-another-tables/m-p/414865#M27268</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;Sorry, but i am confused.&lt;/P&gt;

&lt;P&gt;I have ended up with this but it not working, but i am still referring to myTableSearch at the top of the code and i am unsure how to deal with the issues form the Splunk code where i am referencing 2 things tableid and search ID. &lt;/P&gt;

&lt;P&gt;For one table&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;table id="highlight1"&amp;gt;
        &amp;lt;search id="myTableSearch1"&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;SO i want to be able to say for second table&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;table id="highlight2"&amp;gt;
        &amp;lt;search id="myTableSearch2"&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
     "underscore",
     "jquery",
     "splunkjs/mvc",
     "splunkjs/mvc/searchmanager",
     "splunkjs/mvc/tableview",
     "splunkjs/mvc/simplexml/ready!"
 ], function(_, $, mvc, SearchManager, TableView) {

     var mySearch = splunkjs.mvc.Components.getInstance("myTableSearch");
     var myResults = mySearch.data("results", {count:0});
     var allFields,filteredFields;
     myResults.on("data", function(){
         allFields=myResults.data().fields;
         filteredFields=allFields.filter(filterFields);
         console.log("Filtered Fields:",filteredFields);
     });
     function filterFields(field) {
         return field !== "_time";
     }
     // Row Coloring Example with custom, client-side range interpretation
     var CustomRangeRenderer = TableView.BaseCellRenderer.extend({
         canRender: function(cell) {
             // Enable this custom cell renderer for all fields except TAG
             return _(filteredFields).contains(cell.field);
         },
         render: function($td, cell) {
             // Add a class to the cell based on the returned value
             var value = parseInt(cell.value);

             // Apply interpretation based on count of errors per TAG for each field
             if(cell.field !== "_time"){
                 if (value &amp;gt;= 5) {
                     $td.addClass("range-cell").addClass("range-severe");
                 }
                 else if (value &amp;gt;= 1 &amp;amp;&amp;amp; value &amp;lt; 5) {
                     $td.addClass("range-cell").addClass("range-elevated");
                 }
                 else if (value &amp;lt; 1) {
                     $td.addClass("range-cell").addClass("range-low");
                 }
                 // Update the cell content
                 $td.text(value).addClass("numeric");
             }
         }
     });
      var tableIDs = ["myTableSearch","myTableSearch2","myTableSearch3"];
       for (i=0;i&amp;lt;tableIDs.length;i++) {
           var sh = mvc.Components.get(tableIDs[i]);
           if(typeof(sh)!="undefined") {
               sh.getVisualization(function(tableView) {
                   // Add custom cell renderer and force re-render
                   tableView.table.addCellRenderer(new CustomRangeRenderer());
                   tableView.table.render();
               });
           }
       }    

 });
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 20 Jan 2019 15:50:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-i-re-use-Java-scripts-form-one-table-to-another-tables/m-p/414865#M27268</guid>
      <dc:creator>robertlynch2020</dc:creator>
      <dc:date>2019-01-20T15:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: How can i re-use Java scripts form one table to another tables</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-i-re-use-Java-scripts-form-one-table-to-another-tables/m-p/414866#M27269</link>
      <description>&lt;P&gt;Hi @robertlynch2020&lt;/P&gt;

&lt;P&gt;I had modified the code little bit. Please specify tableid-searchid like below and try &lt;CODE&gt;var table_search_IDs = ["highlight1-myTableSearch1","highlight2-myTableSearch2"];&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
     "underscore",
     "jquery",
     "splunkjs/mvc",
     "splunkjs/mvc/searchmanager",
     "splunkjs/mvc/tableview",
     "splunkjs/mvc/simplexml/ready!"
 ], function(_, $, mvc, SearchManager, TableView) {


     // Row Coloring Example with custom, client-side range interpretation
     var CustomRangeRenderer = TableView.BaseCellRenderer.extend({
         canRender: function(cell) {
             // Enable this custom cell renderer for all fields except _time
             return _(filteredFields).contains(cell.field);
         },
         render: function($td, cell) {
             // Add a class to the cell based on the returned value
             var value = parseInt(cell.value);

             // Apply interpretation based on count of errors per _time for each field
             if(cell.field !== "TAG"){
                 if (value &amp;gt;= 5) {
                     $td.addClass("range-cell").addClass("range-severe");
                 }
                 else if (value &amp;gt;= 1 &amp;amp;&amp;amp; value &amp;lt; 5) {
                     $td.addClass("range-cell").addClass("range-elevated");
                 }
                 else if (value &amp;lt; 1) {
                     $td.addClass("range-cell").addClass("range-low");
                 }
                 // Update the cell content
                 $td.text(value).addClass("numeric");
             }
         }
     });

      //List of table Id's-search Id's
      var table_search_IDs = ["highlight1-myTableSearch1","highlight2-myTableSearch2"];
      for (i=0;i&amp;lt;table_search_IDs.length;i++) {
          var tmp = table_search_IDs[i].split("-");
          var tableId = mvc.Components.get(tmp[0]);
          var searchId = mvc.Components.get(tmp[1]);
          if(typeof(tableId)!="undefined") {
              tableId.getVisualization(function(tableView) {
                  // Add custom cell renderer and force re-render
                  tableView.table.addCellRenderer(new CustomRangeRenderer());
              });
          }
          if(typeof(searchId)!="undefined"){
             var myResults = searchId.data("results", {count:0});
             var allFields,filteredFields;
             myResults.on("data", function(){
                 allFields=myResults.data().fields;
                 filteredFields=allFields.filter(filterFields);
                 console.log("Filtered Fields:",filteredFields);
             });
          }
      }

      function filterFields(field) {
         return field !== "TAG";
     }

 });
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 20 Jan 2019 17:03:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-i-re-use-Java-scripts-form-one-table-to-another-tables/m-p/414866#M27269</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-01-20T17:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: How can i re-use Java scripts form one table to another tables</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-i-re-use-Java-scripts-form-one-table-to-another-tables/m-p/414867#M27270</link>
      <description>&lt;P&gt;@robertlynch2020 there are two pieces to the solution approach adopted for coloring all cells of the table.&lt;BR /&gt;
1) Table ID which is used to apply Custom Cell Renderer.&lt;BR /&gt;
2) Search ID for each table which is used to discard the field on which custom coloring does not need to be applied.&lt;/P&gt;

&lt;P&gt;So for simplicity's sake I have just duplicated code with a run anywhere example. However, you would need to create array of IDs so that you reduce code and create re-usable functionality.&lt;/P&gt;

&lt;P&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/6405i134B5F7B6BB5E6CA/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;Following is the Run anywhere SimpleXML:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="table_custom_cell_color_by_table_id.js"&amp;gt;
  &amp;lt;label&amp;gt;Apply style to multiple tables&amp;lt;/label&amp;gt;
  &amp;lt;row depends="$alwaysHideCSSPanel$"&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;
        &amp;lt;style&amp;gt;
          #highlight1 td {
              background-color: #6DB7C6 !important;
          }
          #highlight1 td.range-low {
              color: #6DB7C6;
          }
          #highlight1 td.range-elevated {
              background-color: #ffc57a !important;
              font-weight: bold;
          }
          #highlight1 td.range-severe {
              background-color: #d59392 !important;
              font-weight: bold;
          }
          #highlight2 td {
              background-color: #6DB7C6 !important;
          }
          */
          #highlight2 td.range-low {
              color: #6DB7C6;
          }
          #highlight2 td.range-elevated {
              background-color: #ffc57a !important;
              font-weight: bold;
          }
          #highlight2 td.range-severe {
              background-color: #d59392 !important;
              font-weight: bold;
          }
        &amp;lt;/style&amp;gt;
      &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table id="highlight1"&amp;gt;
        &amp;lt;search id="myTableSearch1"&amp;gt;
          &amp;lt;query&amp;gt;| makeresults
 | eval data="Limits Preview,0,0,5,82;Trade Insertion,1,56,0,0"
 | makemv data delim=";"
 | mvexpand data
 | makemv data delim=","
 | eval TAG=mvindex(data,0),"00:00:00"=mvindex(data,1),"00:01:00"=mvindex(data,2),"00:02:00"=mvindex(data,3),"00:03:00"=mvindex(data,4)
 | table TAG "00:*"&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;panel&amp;gt;
      &amp;lt;table id="highlight2"&amp;gt;
        &amp;lt;search id="myTableSearch2"&amp;gt;
          &amp;lt;query&amp;gt;| makeresults
 | eval data="Limits Preview,0,0,5,82;Trade Insertion,1,56,0,0"
 | makemv data delim=";"
 | mvexpand data
 | makemv data delim=","
 | eval TAG=mvindex(data,0),"00:00:00"=mvindex(data,1),"00:01:00"=mvindex(data,2),"00:02:00"=mvindex(data,3),"00:03:00"=mvindex(data,4)
 | table TAG "00:*"&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 &lt;CODE&gt;table_custom_cell_color_by_table_id.js&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    "underscore",
    "jquery",
    "splunkjs/mvc",
    "splunkjs/mvc/searchmanager",
    "splunkjs/mvc/tableview",
    "splunkjs/mvc/simplexml/ready!"
], function(_, $, mvc, SearchManager, TableView) {

    var mySearch1 = splunkjs.mvc.Components.getInstance("myTableSearch1");
    var myResults1 = mySearch1.data("results", {count:0});
    var allFields1,filteredFields1;
    myResults1.on("data", function(){
        allFields1=myResults1.data().fields;
        filteredFields1=allFields1.filter(filterFields1);
        console.log("Filtered Fields:",filteredFields1);
    });
    function filterFields1(field) {
        return field !== "TAG";
    }
    // Row Coloring Example with custom, client-side range interpretation
    var CustomRangeRenderer1 = TableView.BaseCellRenderer.extend({
        canRender: function(cell) {
            // Enable this custom cell renderer for all fields except _time
            return _(filteredFields1).contains(cell.field);
        },
        render: function($td, cell) {
            // Add a class to the cell based on the returned value
            var value = parseInt(cell.value);

            // Apply interpretation based on count of errors per _time for each field
            if(cell.field !== "TAG"){
                if (value &amp;gt;= 5) {
                    $td.addClass("range-cell").addClass("range-severe");
                }
                else if (value &amp;gt;= 1 &amp;amp;&amp;amp; value &amp;lt; 5) {
                    $td.addClass("range-cell").addClass("range-elevated");
                }
                else if (value &amp;lt; 1) {
                    $td.addClass("range-cell").addClass("range-low");
                }
                // Update the cell content
                $td.text(value).addClass("numeric");
            }
        }
    });
    var mySearch2 = splunkjs.mvc.Components.getInstance("myTableSearch2");
    var myResults2 = mySearch2.data("results", {count:0});
    var allFields2,filteredFields2;
    myResults2.on("data", function(){
        allFields2=myResults2.data().fields;
        filteredFields2=allFields2.filter(filterFields2);
        console.log("Filtered Fields:",filteredFields2);
    });
    function filterFields2(field) {
        return field !== "TAG";
    }
    var CustomRangeRenderer2 = TableView.BaseCellRenderer.extend({
        canRender: function(cell) {
            // Enable this custom cell renderer for all fields except _time
            return _(filteredFields2).contains(cell.field);
        },
        render: function($td, cell) {
            // Add a class to the cell based on the returned value
            var value = parseInt(cell.value);

            // Apply interpretation based on count of errors per _time for each field
            if(cell.field !== "TAG"){
                if (value &amp;gt;= 5) {
                    $td.addClass("range-cell").addClass("range-severe");
                }
                else if (value &amp;gt;= 1 &amp;amp;&amp;amp; value &amp;lt; 5) {
                    $td.addClass("range-cell").addClass("range-elevated");
                }
                else if (value &amp;lt; 1) {
                    $td.addClass("range-cell").addClass("range-low");
                }
                // Update the cell content
                $td.text(value).addClass("numeric");
            }
        }
    });
    mvc.Components.get("highlight1").getVisualization(function(tableView1) {
        // Add custom cell renderer, the table will re-render automatically.
        tableView1.addCellRenderer(new CustomRangeRenderer1());
    });
    mvc.Components.get("highlight2").getVisualization(function(tableView2) {
        // Add custom cell renderer, the table will re-render automatically.
        tableView2.addCellRenderer(new CustomRangeRenderer2());
    });
});
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 20 Jan 2019 18:50:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-i-re-use-Java-scripts-form-one-table-to-another-tables/m-p/414867#M27270</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-01-20T18:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: How can i re-use Java scripts form one table to another tables</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-i-re-use-Java-scripts-form-one-table-to-another-tables/m-p/414868#M27271</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;Thanks for this, this worked and I understand the example.&lt;/P&gt;

&lt;P&gt;perfect &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Rob&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 17:02:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-i-re-use-Java-scripts-form-one-table-to-another-tables/m-p/414868#M27271</guid>
      <dc:creator>robertlynch2020</dc:creator>
      <dc:date>2019-01-21T17:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: How can i re-use Java scripts form one table to another tables</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-i-re-use-Java-scripts-form-one-table-to-another-tables/m-p/414869#M27272</link>
      <description>&lt;P&gt;HI &lt;/P&gt;

&lt;P&gt;Thanks for you efforts for this question, sorry i have voted @niketnilay answers out of the two.&lt;/P&gt;

&lt;P&gt;Thanks Again for the help&lt;/P&gt;

&lt;P&gt;Rob&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 17:04:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-i-re-use-Java-scripts-form-one-table-to-another-tables/m-p/414869#M27272</guid>
      <dc:creator>robertlynch2020</dc:creator>
      <dc:date>2019-01-21T17:04:05Z</dc:date>
    </item>
    <item>
      <title>Re: How can i re-use Java scripts form one table to another tables</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-i-re-use-Java-scripts-form-one-table-to-another-tables/m-p/414870#M27273</link>
      <description>&lt;P&gt;Welcome &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 17:08:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-i-re-use-Java-scripts-form-one-table-to-another-tables/m-p/414870#M27273</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-01-21T17:08:03Z</dc:date>
    </item>
    <item>
      <title>Re: How can i re-use Java scripts form one table to another tables</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-i-re-use-Java-scripts-form-one-table-to-another-tables/m-p/414871#M27274</link>
      <description>&lt;P&gt;@robertlynch2020 refer to one of my recent answers to dynamically apply custom table renderer to all tables present in a SimpleXML Dashboard. &lt;A href="https://answers.splunk.com/answers/815883/javascript-with-xml-coding.html?childToView=816803#answer-816803"&gt;https://answers.splunk.com/answers/815883/javascript-with-xml-coding.html?childToView=816803#answer-816803&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 19:41:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-i-re-use-Java-scripts-form-one-table-to-another-tables/m-p/414871#M27274</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-04-13T19:41:11Z</dc:date>
    </item>
  </channel>
</rss>

