I'm trying to customize my pop-ups, so that the square mile field is either rounded or one decimal. I am using the LocalLayerWidget and AccessifizrWidget v1.2. (Maybe the option to format fields can be added to this custom widget?) But for now, it would help if I could just format it.
<b>Area Name: </b>{name}<br>
<b>Approx. Sq miles: </b>{SqMi}
Is there a way to write the {SqM} element to round or show only one decimal place? Do I need to modify one of the files directly?
BTW - I tried to see if I could see how the Online pop-up configuration worked, but although it had a quick format option, I could not see any code changes (I have not tested by downloading from WAB online yet).
If there is no easy way, I know a semi quick option would just add a field to my source and use that. Just looking for a simpler answer.
Thanks for your time.
Solved! Go to Solution.
Rebecca,
Formatting a numeric field can be done in the fieldinfos
"fieldInfos": [
{
"fieldName": "SHAPE_AREA",
"label": "Area",
"visible": true,
"format": { "places": 2, "digitSeparator": true }
}
]
I will definitely look at adding this to the Local Layer Widget.
Rebecca,
Formatting a numeric field can be done in the fieldinfos
"fieldInfos": [
{
"fieldName": "SHAPE_AREA",
"label": "Area",
"visible": true,
"format": { "places": 2, "digitSeparator": true }
}
]
I will definitely look at adding this to the Local Layer Widget.
thanks Robert. And thanks for considering adding it to a future version of the widget. It sure would make it easier.
Hi Robert,
When I add the format code into my config_Edit.json file for one of my numeric fields it causes the edit widget to continually spin. Do I need to be putting it somewhere else? Does it matter the WAB dev version?
{ "fieldName": "ACCOUNTNUMBER", "label": "Account Number", "isEditable": true, format: { places: 2, digitSeparator: true } },
Thanks,
Brandon
Brandon,
Try:
{ "fieldName": "ACCOUNTNUMBER", "label": "Account Number", "isEditable": true, "format": { "places": 2, "digitSeparator": true } },
Thanks Robert,
Unfortunately when I make that change it doesn't spin but it also doesn't seem to respect the parameters. I can change it from true to false, change the number of places and the pop-up is the same when editing. Is there something that could be over-riding the config settings?
Thanks,
Brandon
Brandon,
I don't know why the Edit widget is ignoring the formatting.
Thanks Robert. I'll submit an esri ticket and try to post back with any resolution. Thanks for all your efforts.
Brandon
I submitted an esri ticket regarding this issue and was informed that an issue has been logged. NIM083044:Pop-up editing must reflect pop-up settings enabled in the pop-up configuration panel. The issue has been assigned so hopefully this will be resolved soon. I'm not sure if there are other discussion out there that might benefit from this information but if anyone comes across them please add a link here or let me know and I can post the info.
Thanks,
Brandon
There are two different ‘field format’ definitions between Pop-up and Edit widget. You can use the standard Pop-up 'format parameter' show below to format fields in Pop-up:
In WAB, the Edit widget use esri/dijit/editing/Editor dijit, the 'format parameter' of Editor is very simple, the definition is:
'Opt-in to allow the editing of time on a date field. An object with a single boolean property named "time".'
https://developers.arcgis.com/javascript/jsapi/editor-amd.html
So, Edit Widget does not support to format a numeric field