We are working on a Custom Widget.
How do I clear the "Search Widget" (Green) from a Custom widget(Red).
Attaching a snap.
I tried this code.
Solved! Go to Solution.
Muralidhar,
You will need to get a reference to the search widget from your widget. for that you will need add 'jimu/WidgetManager', to your widgets define array.
Then add this new helper function:
_getWidgetConfig: function(widgetName){
var widgetCnfg = null;
arrayUtils.some(WidgetManager.getInstance().appConfig.widgetPool.widgets, function(aWidget) {
if(aWidget.name == widgetName) {
widgetCnfg = aWidget;
return true;
}
return false;
});
if(!widgetCnfg){
/*Check OnScreen widgets if not found in widgetPool*/
arrayUtils.some(WidgetManager.getInstance().appConfig.widgetOnScreen.widgets, function(aWidget) {
if(aWidget.name == widgetName) {
widgetCnfg = aWidget;
return true;
}
return false;
});
}
return widgetCnfg;
},
And call this code:
var widgetCfg = this._getWidgetConfig('Search');
if (widgetCfg) {
var searchWidget = WidgetManager.getInstance().getWidgetByLabel(widgetCfg.label);
if(searchWidget){
searchWidget.searchDijit.set("value", "");
}
}
Muralidhar,
You will need to get a reference to the search widget from your widget. for that you will need add 'jimu/WidgetManager', to your widgets define array.
Then add this new helper function:
_getWidgetConfig: function(widgetName){
var widgetCnfg = null;
arrayUtils.some(WidgetManager.getInstance().appConfig.widgetPool.widgets, function(aWidget) {
if(aWidget.name == widgetName) {
widgetCnfg = aWidget;
return true;
}
return false;
});
if(!widgetCnfg){
/*Check OnScreen widgets if not found in widgetPool*/
arrayUtils.some(WidgetManager.getInstance().appConfig.widgetOnScreen.widgets, function(aWidget) {
if(aWidget.name == widgetName) {
widgetCnfg = aWidget;
return true;
}
return false;
});
}
return widgetCnfg;
},
And call this code:
var widgetCfg = this._getWidgetConfig('Search');
if (widgetCfg) {
var searchWidget = WidgetManager.getInstance().getWidgetByLabel(widgetCfg.label);
if(searchWidget){
searchWidget.searchDijit.set("value", "");
}
}
Thank you so much. This code worked perfectly.
Don't forget to mark this question as answered by clicking on the "Mark Correct" link on the reply that answered your question.