Is there any way to initiate an eSearch query outside of eSearch. Is it possible, for example, to send a query that will open eSearch, use the eSearch widget to run a query on a particular layer and update the AttributeTable widget?
Solved! Go to Solution.
Tom,
Correct the url search is just for doing a search on app start. For you do do a search using eSearch widget from another widget then you would have to get a reference to the eSearch widget using WidgetManager and then call the search function like this
eSearchWidget.search(null, slayerId, exprNum, valsArr, null, false);
Tom,
The eSearch widget has a documented URL Search parameters section in the help.
Robert,
Ok I read the help. In my case I want to take the parcel number from one widget in a WAB app and send it through the eSearch widget in the same app. Is that possible?
This is the expression I would use:
?esearch=1819251005&slayer=7&exprnum=0
Or is this just designed to fire off outside of the WAB app? Something like this:
https://gis.xxxx.com/wab_dev/?esearch=1819251005&slayer=7&exprnum=0
Tom
Tom,
Correct the url search is just for doing a search on app start. For you do do a search using eSearch widget from another widget then you would have to get a reference to the eSearch widget using WidgetManager and then call the search function like this
eSearchWidget.search(null, slayerId, exprNum, valsArr, null, false);
Robert,
That makes sense. I can see where both options could come in handy.
Thanks for your help and quick response.
Tom
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:
Anish,
So based on this code:
eSearchWidget.search(null, 0, 9, parcelid, null, false);
You have 10 different expressions configured for the first layer in the eSearch widget?..
Robert,
There are 10 different Search layers and the layer I am intending to search is the very last and that one has only one search expression.
OK. So you have the zero and nine reversed then
eSearchWidget.search(null, 9, 0, parcelid, null, false);
I am still seeing the error message after the change. I deleted all the browsing history data just incase but I am still having the same issue. Here is the screenshot.