Splunk Search

How to get the clicked value using javascript

madanashok
Path Finder

Hi,

Iam using simpleresultstable module with pager to show results like below.

a link

View http://www.some url
View http://www.some url
View http://www.some url

Now in application.js i use this following code to show the value when clicked.

switch (Splunk.util.getCurrentView()) {
case "dd1":
if (Splunk.Module.NullModule) {
Splunk.Module.NullModule = $.klass(Splunk.Module.NullModule, {
getModifiedContext: function() {

             var name = this.getContext().get("click.name");

               var val = this.getContext().get("click.value");
                 if (name == "a") {
                               alert(val);
              }
                return context;
            }
        });
    }
    break;

}

when i click the table it shows only the first column value in message box.

I want to get the clicked value in MessageBox.

Thanks

Tags (1)
0 Karma

joelzyla
Explorer

Jquery, which is built into Splunk, could be used.

http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CC8QFjAA&url=http%3A%2F%2Fapi.jq...

(the .live has been replaced with .on in the current version of Jquery, but Splunk is using version 1.6, so .live will work.

if (Splunk.util.getCurrentView() == 'your_view_name' ) {

   $(".myButtonClass").live("click", function(event){
   event.preventDefault(); 
   var txt = $(this).text();
   var url = $(this).url();
   alert(txt);
   alert(url);
   });
}
0 Karma

Ayn
Legend

What kind of drilldown are you using, row or all? You need to have drilldown set to all in your SimpleResultsTable module and then use the variable click.value2 to get the contents of the specific cell that is clicked. click.value just gives you the value of the first cell in the row clicked.

http://docs.splunk.com/Documentation/Splunk/5.0/AdvancedDev/TableChartDrilldown

madanashok
Path Finder

No I am not using any drill down here.Iam using javascript code to get the value in message box.

I found there is a possibilty to get the clicked value in message box.

The above table shows a and link columns.Iam displaying that using simpleresultstable module.When i click any cell value(second column cell value) it loads application.js file and after executing the script it shows the first column cell value only.But I want to get the link value say that(http://someurl).

0 Karma
Get Updates on the Splunk Community!

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

Get Inspired! We’ve Got Validation that Your Hard Work is Paying Off

We love our Splunk Community and want you to feel inspired by all your hard work! Eric Fusilero, our VP of ...

What's New in Splunk Enterprise 9.4: Features to Power Your Digital Resilience

Hey Splunky People! We are excited to share the latest updates in Splunk Enterprise 9.4. In this release we ...