How to clear or reset a form element
I have a form with a drop down list and a geometry picker where the users selects two points on the map. I would like the geometry picker to reset and remove any existing points if the drop down list value changes.
Is it possible to reset or clear a form element?
I've had some success using a "Set Form Element Property" activity where I set the geometry value to blank and also remove the graphics layer of the geometry picker from the map. This removes the geometries from the form and resets the add geometry button back to blue, but when I try to add new geometries the points don't show up on the map. The new geometries exist as a I have a query activity that runs on change of the geometry picker, which is working fine.
Wondering if anyone can help?
Thanks,
Carl
-
Hi Carl,
It looks like the geometry picker has a "state" property (an array) that's key to displaying and interacting with the selected geometry.
Try adding a Clear Collection activity in your change event subworkflow, after the activity that clears the geometry value. For the collection value, use =$form1.state.geometryPicker1.state (or the equivalent to match your id's).
You mentioned that your change event also removes the graphics layer of the geometry picker from the map. I would take this step out before testing with this change. It shouldn't be necessary to remove any out-of-the-box graphics layers manually (but if you added your own graphics layers somewhere then you might still want to).
0 -
Thanks, Amanda! This does exactly what I need.
It wasn't necessary to remove the graphics layer to get this to work.
0 -
This does not seem to work for me...
I have a geometryPicker with which I would like the user to click on the map. I will then use this point to query a polygon layer. If no polygon is found at the clicked location, I want the geometryPicker to "reset" (and if possible reuse the 'Auto-Activate' capability of the geometryPicker), so that the user does not need to delete the previous point.
I tried using the 'Clear Collection' with =$form1.state.geometryPicker1.state. It does not do anything for me...
Any help is appreciated
0 -
Use a "Set Form Element Property" activity:
Element: =$form1.state.geometryPicker1
Property Name: value
Leave the rest blank.
After that Activity add this:
Activity: Set Form Element Property
Element: =$form1.state.geometryPicker1
Property Name: autoActivate
Property Value: true
0 -
@Nelson Dobbs? This method works fine to clear the geometry. However, after adding a new geometry with the same geometry picker, I find that the old geometry gets restored instead. Or at least the markup of the old geometry: I can retrieve the value of the new geometry, but the yellow markup that shows is from the first added geometry. Any ideas how that works..? How can I also reset the Graphics Layer/Markup of the geometry picker?
0 -
Using Clear Collection to clear an Item Picker's state doesn't seem to work in Geocortex Mobile. Error says: "Input collection was invalid. Expected type System.Collections.IList". Looking at the input to Clear Collection, I see it is a System.Collections.Generic.List. This class implements the IList-interface, so this should not be a problem. @Amanda Frech?
0 -
@Jostein Svegården? What's your input on the Clear Collection activity? You mentioned clearing an Item Picker- are you referencing a property directly from the item picker form element, or some other value that's used to later generate the form element items? Just looking for a way to try to test this out on my end accurately.
0 -
Input is $form1.state.geometryPicker1.state - just the same as you proposed at the top of this post
0
Please sign in to leave a comment.
Comments
8 comments