Select to view content in your preferred language

How can I customize the query widget?

3804
22
Jump to solution
11-17-2017 10:12 PM
VatsalDave2
Emerging Contributor

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.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

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);
          }));
        }
      },‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

22 Replies
RobertScheitlin__GISP
MVP Emeritus

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);
          }));
        }
      },‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
VatsalDave2
Emerging Contributor

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

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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.

0 Kudos
VatsalDave2
Emerging Contributor

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

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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.

0 Kudos
VatsalDave2
Emerging Contributor

Thanks for your very quick response.

I am attaching screenshots hoping it explains.

The application is on a client site and I access through AnyDesk.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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.

0 Kudos
VatsalDave2
Emerging Contributor

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

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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.

0 Kudos