About query widget - field data type

3960
6
Jump to solution
07-28-2015 04:17 PM
LeiZhou1
New Contributor III

I set up a search layer in the WAB query widget. There is one field 'Zip code', which is a numerical value defined by map service. So it always displays as 33,098 instead of 33098. Is there any method that I can change its format in the query widget? I know the format can be adjusted in web map pop-up window, but inside a query widget, can it be changed? Thanks!

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Lei,

  There is no configuration in place for this. But you can easily add code to handle this. Open the Query Widget.js file and around line 1131 replace:

              fieldValue = this._tryLocaleNumber(fieldValue);

with:

              if(fieldAlias !== "Zip code"){
                fieldValue = this._tryLocaleNumber(fieldValue);
              }

View solution in original post

6 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Lei,

  There is no configuration in place for this. But you can easily add code to handle this. Open the Query Widget.js file and around line 1131 replace:

              fieldValue = this._tryLocaleNumber(fieldValue);

with:

              if(fieldAlias !== "Zip code"){
                fieldValue = this._tryLocaleNumber(fieldValue);
              }
LeiZhou1
New Contributor III

Hi, Robert,

I did not find the code this._tryLocaleNumber(f)) in line 1131, but I found one from line 1852, the original code is like

f = this._tryLocaleNumber(f));

I changed that to

if(c!== "Zip_Code") {f = this._tryLocaleNumber(f));}

When I run it, the query failed. I am not sure is the variable c represent a alias name?

Or are you saying the line 1125,

 _tryLocaleNumber: function (a) {
            var b = s.localizeNumber(a);
            if (null === b || void 0 === b) b = a;
            return b
        },

Thanks a lot!

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Lei,

   It sounds like you are using a minified version of the widget and not the source code that comes with Web AppBuilder Dev.

0 Kudos
LeiZhou1
New Contributor III

What I do is to finish an app using AGO account (web version, not developer edition), then download the app and work on the source code. The reason is that the developer version is 4 weeks later than the web version, and we want the new effect, widgets, and themes now -- the Dev version does not provide those now.

I never know this: the query widget in web version is different from the query widget in developer version, right? If this is true, what is the difference between these two?

When the latest developer version is coming out, I will definitely select the enhanced search widget instead of query widget. The difference is so obvious. Currently, I just can not use that great widget in our web version; the Built-in Query widget is my only choice.  Thanks!

0 Kudos
LynneHamlin
New Contributor II

I had the same problem with WAB query widget and here's ESRI's response:

This is a known bug (#BUG-000086319 Numeric field types within the attribute table in the Web AppBuilder still show the thousand comma that were removed in the webmap in arcgis online) and is scheduled to be fixed as part of the next AGOL update.

The only workaround is to make the field type as string (text) instead of numeric (i.e. zipcodes) before bringing into ArcGIS Online. This way the webmap will not have a comma by default and it will come into the Web AppBuilder attribute table with no comma as well.

LeiZhou1
New Contributor III

Thanks for that information!

0 Kudos