In my web application I am able to add widgets and also change the rights of widgets from confing.json file,But this change is permanently. And I want the property of the widget to be enabled or disabled programatically at the run time using java-script API.Please suggest how to do it.
It's possible. Just publish an appConfig object with the new configuration using the appConfigChanged event name.
Here is a sample code that you could paste in chrome console to see it working with your Web AppBuilder project:
var topic = require('dojo/topic')
function showWidget(widgetId, trueOrFalse) {
var appConfig = getAppConfig();
var widgetsFound = appConfig.widgetPool.widgets.filter( widget => widget.id === widgetId );
if(widgetsFound.length > 1){
throw Error('More than 1 widget with the same id ' + widgetsFound[0].id + '. ');
}
if(widgetsFound.length == 1){
var widget = widgetsFound[0];
widget.visible = trueOrFalse;
topic.publish("appConfigChanged", appConfig, 'attributeChange', {});
}
}
And then call:
showWidget(yourWidgetId, false);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.