< search id= 'pie_search'> < query>index=mtest1 | stats sum(num) by fruit</query> < /search>
var mySearch = mvc.Components.get('pie_search'); mySearch.startSearch();
Uncaught TypeError: Cannot read property 'startSearch' of undefined
Can anyone please tell me what I am missing?
It doesn't work for me. The error is the same.
However, I can use both "var mySearch = splunkjs.mvc.Components.getInstance("search1") " and "var mySearch = mvc.Components.get('search1');" to get the object of searchManager in my js file.
The problem is that I can't get the object according to the "id" of search label, like "var mySearch = mvc.Components.get('pie_search')". No matter how I change the "id" of search label, the only way to acquire the object is by the "id" search1.
When you open the dashboard in your browser and check the html code, can you see your searches in the script part after the layout part? They should be after the part about tokens, and there you can confirm what id they have. It looks like somehow, your id isn't set correctly, but I assume you have other searches (without unique ids) which you then select with "search1" and "search2".
I find out that I can add id attribute of my search from 6.2. And that really makes sense.
Actually, before 6.2 (like 6.1), there is no id attribute of search, and splunk will give the id to search by default. The default id will be search1, search2...according to the sequence of searches.
Oh! Confer http://docs.splunk.com/Documentation/Splunk/6.1/Viz/PanelreferenceforSimplifiedXML to see that in 6.1, there is no such thing as an id attribute of your search. That is introduced later. Only your panels have ids, I don't know if you can access your search from the id of your panels.