I would like to know whether it´s possible to add or remove specified widgets on runtime.
form example i press any tool on my toolbar and add widget to sidebar . press again to remove widget.
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityI would like to know whether it´s possible to add or remove specified widgets on runtime.
form example i press any tool on my toolbar and add widget to sidebar . press again to remove widget.
Adding widgets is not difficult. you can use topic.publish('viewer/loadWidget')
Removing them can be more problematic - depends on the widget and whether it properly cleans up after itself. ;)
I have accomplished the same thing by loading all the widgets at the start and showing/hiding the desired widget using css. Roughly something like this :
domStyle.set(dom.byId('find_parent'), 'display', 'block');
domStyle.set(dom.byId('find_parent'), 'display', 'none');
In this case find_parent
is the id for the titlePane widget that contains the CMV Find widget. Note that I don't usually use dom.byId
for this. It is a simple example of one option.
Would this approach work for you?
thanks dear tmcgee. this work for me.
<script>
require(["dojo/dom-style", "dojo/dom", "dojo/on", "dojo/domReady!"],
function (style, dom, on) {
on(dom.byId("btnidentify"), "click", function () {
var p_identify = dom.byId("identify_parent");
if (p_identify.style.display === 'none') {
p_identify.style.display = 'block';
} else {
p_identify.style.display = 'none';
}
});
});
</script>