Select to view content in your preferred language

InfoWindow and currency number format

2719
5
10-09-2012 05:12 AM
deleted-user-pYdfRjvSAbTJ
Deactivated User
Hello,
Is there a way to format a number in the InfoWindow as currency?
or better, is there a way to use field informations (field format, field alias, field visibility) stored into the mxd project published in ArcGIS Server?
5 Replies
__Rich_
Deactivated User
You can format values in the infoWindow using the template as described here:

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/intro_formatinfowindow.htm

Note that there's only out-the-box support for dojo.number.format for your scenario, which you could use if you're clever with the options.  Alternatively, if you wanted to hook up dojo.currency.format then you could using the "Custom Function" pattern as described in the above.

You could certainly 'peek' at the field metadata to aid decisions at runtime, I'm guessing you'd like this formatting to happen automatically for every currency field, right?
0 Kudos
deleted-user-pYdfRjvSAbTJ
Deactivated User
thank you for your response
let me understand: you are saying that there's no out of the box support to mxd field settings...
I have to manually format my field values using a template, so if I want something automatic I have to develop myself a sort of field value builder
great...
but why the rest API "htmlPopup" return a table with all the values formatted as in the mxd project?
0 Kudos
__Rich_
Deactivated User

but why the rest API "htmlPopup" return a table with all the values formatted as in the mxd project?

That's a different question really and involves a different operation namely HTML Popup where the values are formatted server-side according to whatever's defined by the Desktop author.

Perhaps it suits your purpose, as long as the settings for formatting values are appropriate for all your users.  (e.g. do you have an international client base?)

The other server-side formatting that I'm aware of is that Identify will format the values according to the data type that you've set in ArcMap in the Appearance section of the Fields tab on the layer properties dialog, note that this formatting won't be present for Query operations.  (Identify and Query return values differently e.g. dates - there's a few threads on this in the forum)

Note that if you decide you want to do the formatting client-side (as per my previous post) then to my knowledge you won't have any indication as to which fields to format as currency and which to format as number - the data type in the field info for both fields (for the kind of data you're using) will be esriFieldTypeDouble.

Hopefully this provides you with enough information to make your choice, if not then perhaps someone else knows more...
0 Kudos
deleted-user-pYdfRjvSAbTJ
Deactivated User
thanks again...
i really don't understand the reasons behind the differences between Identify/HtmlPopup/Query
I'll try to choose the better option
0 Kudos
__Rich_
Deactivated User
thanks again...
i really don't understand the reasons behind the differences between Identify/HtmlPopup/Query
I'll try to choose the better option

I'll try to summarise:


  • Identify - you'll get back the values formatted as per the settings in ArcMap but you can re-format client-side if you need to.

  • HTML Popup - you'll get back a blob of HTML formatted as per the settings in ArcMap, just blindly inject this into your page and you'll see the table (or whatever you've determined via the ArcMap settings)

  • Query - you'll get the values back unformatted so you will have to format them client-side


I suppose the advantage of client-side formatting is you can use the personal settings (locale etc.) of your user to ensure that they see values in a format that makes sense to them, the advantage of server-side formatting is that the Desktop user can determine what all the web users will see...but it doesn't know, for example, which locale they have so therefore, for example, it can't determine whether to use a comma or period for decimal separation.

With currencies, it might be better to format server-side to ensure consistency - think about conversion rates etc.

HTH

(this information may not be complete I've just tried to highlight the differences that I think are important to your situation!)
0 Kudos