I need the solution for clearing the input parameters on selecting "clear this result" in the Query widget. Will appreciate a quick response from Esri Tech Support.
Solved! Go to Solution.
Vatsal,
Here is a code solution to your request (Widget.js lines 27, 33 and 49 -54):
define([
'dojo/on',
'dojo/query',
'dojo/Deferred',
'dojo/_base/lang',
'dojo/_base/html',
'dojo/_base/array',
'dojo/promise/all',
'dojo/_base/declare',
'dijit/_WidgetsInTemplateMixin',
'jimu/utils',
'jimu/BaseWidget',
'jimu/MapManager',
'jimu/filterUtils',
'jimu/dijit/Message',
'esri/lang',
'esri/request',
'esri/symbols/jsonUtils',
'esri/layers/FeatureLayer',
'esri/dijit/PopupTemplate',
'esri/renderers/SimpleRenderer',
'./TaskSetting',
'./SingleQueryLoader',
'./SingleQueryResult',
'./utils',
'jimu/LayerInfos/LayerInfos',
'dijit/registry',
'jimu/dijit/LoadingShelter',
'dijit/form/Select'
],
function(on, query, Deferred, lang, html, array, all, declare, _WidgetsInTemplateMixin, jimuUtils, BaseWidget,
MapManager, FilterUtils, Message, esriLang, esriRequest, symbolJsonUtils, FeatureLayer, PopupTemplate,
SimpleRenderer, TaskSetting, SingleQueryLoader, SingleQueryResult, queryUtils, LayerInfos, registry) {
.....
removeSingleQueryResult: function(singleQueryResult){
var value = null;
array.some(this._resultLayerInfos, lang.hitch(this, function(resultLayerInfo){
if(resultLayerInfo.singleQueryResult === singleQueryResult){
value = resultLayerInfo.value;
return true;
}else{
return false;
}
}));
if(value !== null){
this._removeResultLayerInfoByValues([value]);
//todo clear inputs
var spDoms = query('.jimu-filter-value-provider', this.tbody);
array.forEach(spDoms, lang.hitch(this, function(spDom){
var sp = registry.byNode(spDom.children[0]);
sp.set("value", null);
}));
}
},
Vatsal,
Here is a code solution to your request (Widget.js lines 27, 33 and 49 -54):
define([
'dojo/on',
'dojo/query',
'dojo/Deferred',
'dojo/_base/lang',
'dojo/_base/html',
'dojo/_base/array',
'dojo/promise/all',
'dojo/_base/declare',
'dijit/_WidgetsInTemplateMixin',
'jimu/utils',
'jimu/BaseWidget',
'jimu/MapManager',
'jimu/filterUtils',
'jimu/dijit/Message',
'esri/lang',
'esri/request',
'esri/symbols/jsonUtils',
'esri/layers/FeatureLayer',
'esri/dijit/PopupTemplate',
'esri/renderers/SimpleRenderer',
'./TaskSetting',
'./SingleQueryLoader',
'./SingleQueryResult',
'./utils',
'jimu/LayerInfos/LayerInfos',
'dijit/registry',
'jimu/dijit/LoadingShelter',
'dijit/form/Select'
],
function(on, query, Deferred, lang, html, array, all, declare, _WidgetsInTemplateMixin, jimuUtils, BaseWidget,
MapManager, FilterUtils, Message, esriLang, esriRequest, symbolJsonUtils, FeatureLayer, PopupTemplate,
SimpleRenderer, TaskSetting, SingleQueryLoader, SingleQueryResult, queryUtils, LayerInfos, registry) {
.....
removeSingleQueryResult: function(singleQueryResult){
var value = null;
array.some(this._resultLayerInfos, lang.hitch(this, function(resultLayerInfo){
if(resultLayerInfo.singleQueryResult === singleQueryResult){
value = resultLayerInfo.value;
return true;
}else{
return false;
}
}));
if(value !== null){
this._removeResultLayerInfoByValues([value]);
//todo clear inputs
var spDoms = query('.jimu-filter-value-provider', this.tbody);
array.forEach(spDoms, lang.hitch(this, function(spDom){
var sp = registry.byNode(spDom.children[0]);
sp.set("value", null);
}));
}
},
You are truly awesome, Robert. I just can’t thank you enough for the great service.
You are an inspiration.
Please do not mind me picking your brains for trivialest of issues.
I have been using your widgets profusely and your help like this helps solve so many of my problems!!
Thanks once again.
Vatsal
Glad to hear it. Don’t forget to mark this question as answered by clicking on the “Correct Answer” link for the reply that answered your question.
Hi Robert,
I applied your code solution to the query widget and it ran perfectly for 12 of my 16 applications.
In 4 applications, however, I am facing a strange outcome.
For example, one of these applications four query parameters: Zone, Ward, Type of Facility, and Facility. The 2nd, 3rd and 4th filtered by previous expression.
The user selects a zone, ward, and Type of Facility from the drop down and runs “Execute” without any selection of the Facility. The tool runs and shows all the facility of the type (say “Hospitals”) in the selected Ward of the selected Zone.
Now when I clear results and go back to tasks, I find the “Facility” populated automatically by one facility and I cannot remove that. If I try to backspace and erase, I get the Facility drop down forcing me to select one. Only after I select a new Zone/Ward/Facility Type and remove the populated value, I can remove it.
Whichever Zone, Ward or Facility Type I select, I get the same value in the automatically populated “Facility” field.
The same thing happens in three other applications.
Please help.
With regards,
Vatsal
p.s. This happens when the query is run for the first time and after each application refresh
I have tried to reproduce your issue and I am not able to... It is hard for me to debug this if I can not reproduce it.
Vastal,
I have setup the widget using unique values for four field just like that, where values are filtered by previous expressions and I don't get this issue. Maybe you could provide you widgets config file for comparison.
Hi Robert,
Is there an e-mail id where I can share things?
I do not think the culprit is four fields. This happens only the first time a query is run in a new session and only when no value is selected for the fourth field.
Which is the widget config file I need to send? Is it WAB/server/apps/#/widgets/Query/config.json?
Regards,
Vatsal
Vatsal,
The config is [install dir]\server\[app#]\configs\Query\config_Query.json. You can just paste the section for one of your layers that is failing in the reply.