hi,
I want to add a custom button in the dashboard for the following data
can someone please help me on how to proceed with these as if new to this?
EXAMPLE DATA:
macro
micro
alpa
When I click on macro button it should show me the following result:
RESULT macro:
atom
electron
similarly when I click on micro button it should give me only micro result and not macro:
RESULT micro:
neutron
proton
@ashwinipatil007
try this
<input type="link" id="submit_button" token="Submit" searchWhenChanged="true" depends="SERVERS">
<label></label>
<choice value="submit">Submit</choice>
</input>
Style
<style>
#submit_button label {
color: #fff701;
font-size: 12px;
}
</style>
You can use inbuilt inputs like dropdown or radio buttons.
<form>
<label>Label</label>
<fieldset submitButton="true">
<input type="radio" token="field1">
<label>Select option:</label>
<choice value="macro">macro</choice>
<choice value="micro">micro</choice>
<choice value="alpa">alpa</choice>
<default>macro</default>
</input>
</fieldset>
<row>
<panel depends="$field1$">
<title>Panel 1</title>
<table>
<search>
<query>USE $field1$ in your search query.</query>
</search>
</table>
</panel>
</row>
</form>
I actually want to use Onclick button , not the radio or dropdown.
so is there any piece of code which works for on click button?
or if can write it in js or html code kindly let me know
Then you can add button in dashboard using html.
<row>
<html>
<button id="macro" class="btn btn-primary">Macro</button>
<button id="micro" class="btn btn-primary">Micro</button>
</html>
</row>
Then in js you can implement onclick.
require([
"splunkjs/mvc",
"splunkjs/mvc/simplexml/ready!"
], function(mvc) {
var tokens = mvc.Components.get("default");
$('#macro').on("click",function(){
tokens.set("macro", "Macro");
tokens.unset("micro");
});
$('#micro').on("click",function(){
tokens.set("micro", "Micro");
tokens.unset("macro");
});
});
Sample xml:
<form>
<init>
<set token="macro">Macro</set>
<set token="micro">Micro</set>
</init>
<label>Label</label>
<row>
<html>
<button id="macro" class="btn btn-primary">Macro</button>
<button id="micro" class="btn btn-primary">Micro</button>
</html>
</row>
<row depends="$macro$">
<panel>
<title>Panel Macro</title>
</panel>
</row>
<row depends="$micro$">
<panel>
<title>Panel Micro</title>
</panel>
</row>
</form>
appreciate for your quick response :)but thehtml code is not working as expected,when I click on macro it is not showing the title ,similary when I click on micro it is not showing the result.
tried with the exact code also which you gave still no luck!
tested the function of js script with an alert it is working fine.but not sure of the html and xml code