Hi all,
I'm developing a custom dashboard and it's required that when a button is clicked, the associated panel reloads
(only that panel, not the entire dashboard). Is there a way of doing it through javascript??
Thanks in advance.
Regards
@pbalbasm
Can you please try this?
id
to your panels search. like id="my_search"
mvc.Components.get("my_search").startSearch();
Thanks
Hi @kamlesh_vaghela
Did not work for me ☹️
My code is as below:
$("#submit_button").click(function($){
if(typeof submittedTokens.get("element") === 'undefined'){
mvc.Components.get("panel_id").startSearch();
}
});
This is the xml part
<form script="script.js" >
<label>App</label>
<row>
<panel>
<html depends="$hide$">
<style>
#submit_button{
width:80px !important;
}
#submit_button div[data-component="splunk-core:/splunkjs/mvc/components/LinkList"]{
width:80px !important;
}
#submit_button button{
padding: 6px 15px !important;
border-radius: 3px !important;
font-weight: 500 !important;
background-color: #5cc05c !important;
border: transparent !important;
color: #fff !important;
}
#submit_button button:hover{
background-color: #40a540 !important;
border-color: transparent !important;
}
</style>
</html>
....
<input type="link" id="submit_button">
<label></label>
<choice value="submit">Submit</choice>
</input>
</panel>
</row>
<row>
<panel id="panel_id">
<table>
<search>
<query>index=*
| stats latest(element) by value</query>
<earliest>$earliest$</earliest>
<latest>$latest$</latest>
</search>
<option name="refresh.display">progressbar</option>
</table>
</panel>
</row>
</form>
You should define id for search tag Not panel tag.
like..
<panel>
<table>
<search id="panel_id">
KV
@kamlesh_vaghelaThank you, it works now
Hi,
I am looking for the same. I am not good at javascript. I have tried below but its not working
require([
"splunkjs/mvc",
"splunkjs/mvc/simplexml/ready!"
], function(
mvc
) {
mvc.Components.get("my_search").startSearch();
});
Can someone pls help.
Thanks
@pbalbasm
Can you please try this?
id
to your panels search. like id="my_search"
mvc.Components.get("my_search").startSearch();
Thanks
Hi, that totally work! Thank you.
Great @pbalbasm. Can you please upvote and accept to close this question?
It works! Thank you very much!
Hi @pbalbasm,
There's already a refresh button under every panel in Splunk. Is that what you are trying to recreate ?
Yes, it's something similar what I need to do.