Hi Robert,
I am trying to create a custom feature action in webmap popup which basically passes the value of the feature clicked to the eSearch WIdget and perform a search. I have been able to successfully add the feature action to the popup and it opens the eSearch widget, but when trying to use the Search function like you mentioned above, I get an error message saying "Search failed". Looking at the console, it looks like it is sending an empty String to the function.
I would appreciate any help.
Here is my feature action code :
define([
'dojo/_base/declare',
// 'esri/graphicsUtils',
'../BaseFeatureAction',
'jimu/utils',
'jimu/WidgetManager',
'jimu/PanelManager',
'dojo/_base/array'
], function(declare, /*graphicsUtils,*/ BaseFeatureAction, utils, WidgetManager, PanelManager, array){
var clazz = declare(BaseFeatureAction, {
name: 'ShowShwComplaints',
iconClass: 'icon-statistics',
isFeatureSupported: function(featureSet){
return featureSet.features.length > 0 && featureSet.geometryType !== 'point';
},
onExecute: function(featureSet){
var parcelid = featureSet.features[0].attributes.RP_ACCT_ID;
wManager = WidgetManager.getInstance();
wManager.triggerWidgetOpen("widgets_eSearch_Widget_23");
var widgetCfg = this._getWidgetConfig('eSearch');
console.log("Widget config value: " + widgetCfg);
console.log("Widget config label : "+widgetCfg.label);
setTimeout(function() {
var eSearchWidget = wManager.getWidgetByLabel(widgetCfg.label);
console.log("esearch widget value : " + eSearchWidget);
console.log("Parcel id: "+parcelid);
//https://localhost/myapp/?esearch=1663590&slayer=9&exprnum=0
eSearchWidget.search(null, 0, 9, parcelid, null, false);
}, 3000);
},
_getWidgetConfig: function(widgetName){
var widgetCnfg = null;
array.some(WidgetManager.getInstance().appConfig.widgetPool.widgets, function(aWidget) {
if(aWidget.name == widgetName) {
console.log("aWidget Name : "+ aWidget.name + " Passed value : " + widgetName);
widgetCnfg = aWidget;
return true;
}
return false;
});
if(!widgetCnfg){
/*Check OnScreen widgets if not found in widgetPool*/
array.some(WidgetManager.getInstance().appConfig.widgetOnScreen.widgets, function(aWidget) {
if(aWidget.name == widgetName) {
widgetCnfg = aWidget;
return true;
}
return false;
});
}
return widgetCnfg;
}
});
return clazz;
});
Here is the console message I am getting: