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!
Solved! Go to Solution.
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); }
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); }
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!
Lei,
It sounds like you are using a minified version of the widget and not the source code that comes with Web AppBuilder Dev.
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!
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.
Thanks for that information!