import BatchAttributeFormViewModel from "@arcgis/core/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js";
const BatchAttributeFormViewModel = await $arcgis.import("@arcgis/core/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js");
@arcgis/core/widgets/BatchAttributeForm/BatchAttributeFormViewModel
Provides the logic for the BatchAttributeForm widget.
Known Limitations
- Currently, editing relationship elements and Attachments and are not supported within this widget. Users can edit related records and attachments individually using the FeatureForm widget.
- Editing utility network associations is not supported within this widget. Users can edit association fields individually using the FeatureForm widget.
- Text elements are not supported within this widget.
- The widget does not support editing features from layers with contingent values.
- See also
let batchAttributeForm = new BatchAttributeForm({
viewModel: { // Autocasts as new BatchAttributeFormViewModel()
map: map, // Required if using Arcade expressions that use the global $map variable
features: featureCollection,
},
container: "batchAttributeFormDiv"
});
Constructors
-
Parameterproperties Objectoptional
See the properties for a list of all the properties that may be passed into the constructor.
Property Overview
Name | Type | Summary | Class |
---|---|---|---|
The active feature in the form, which is the feature that is currently being edited while in | BatchAttributeFormViewModel | ||
The index of the active feature that is currently being edited. | BatchAttributeFormViewModel | ||
Returns the batch attribute form inputs that are currently being edited. | BatchAttributeFormViewModel | ||
Indicates whether the form is currently evaluating Arcade expressions. | BatchAttributeFormViewModel | ||
The name of the class. | Accessor | ||
Indicates whether the associated view should be in | BatchAttributeFormViewModel | ||
The type of edit operation the form is being used for. | BatchAttributeFormViewModel | ||
Indicates whether any of the Arcade expressions in the form have failed to evaluate. | BatchAttributeFormViewModel | ||
The collection of features whose attributes are being edited. | BatchAttributeFormViewModel | ||
Indicates whether the form has too many features to be loaded with forms containing complex Arcade expressions. | BatchAttributeFormViewModel | ||
Indicates whether the form has too many features to be loaded. | BatchAttributeFormViewModel | ||
Indicates whether there are any visible inputs in the form. | BatchAttributeFormViewModel | ||
Returns an array of features that are invalid, meaning they have at least one invalid attribute value. | BatchAttributeFormViewModel | ||
An array of layers included in the batch attribute form. | BatchAttributeFormViewModel | ||
A reference to the associated Map. | BatchAttributeFormViewModel | ||
The mode of the form, which can be either | BatchAttributeFormViewModel | ||
Indicates whether the form is in a read-only state. | BatchAttributeFormViewModel | ||
Indicates whether the view model is ready to be used. | BatchAttributeFormViewModel | ||
Indicates whether the user has attempted to submit the form. | BatchAttributeFormViewModel | ||
The time zone used to interpret date values in the form. | BatchAttributeFormViewModel | ||
Indicates whether any values, for any features, have been modified by the user. | BatchAttributeFormViewModel | ||
Indicates whether there are any validation errors for any fields for any features. | BatchAttributeFormViewModel | ||
An array of visible inputs in the active form. | BatchAttributeFormViewModel |
Property Details
-
The active feature in the form, which is the feature that is currently being edited while in
single
mode. If themode
isbatch
, this property will benull
.
-
activeFeatureIndex
activeFeatureIndex Number
-
The index of the active feature that is currently being edited. This will be
-1
when mode isbatch
. To entersingle
mode, set this property to the index in the features array of the feature you wish to edit individually. To enterbatch
mode, set this property to-1
.- Default Value:-1
-
activeForm
activeForm BatchFormInputsreadonly
-
Returns the batch attribute form inputs that are currently being edited. This is dependent on the form's mode. If the mode is
batch
, it returns the shared form inputs. Ifsingle
, it returns the form inputs for the active feature. This property is read-only and should not be modified directly. To change which form is active, see activeFeatureIndex.
-
calculating
calculating Booleanreadonly
-
Indicates whether the form is currently evaluating Arcade expressions. This is
true
when the form is evaluating expressions or when it is waiting for a response from the server.
-
disabled
disabled Boolean
-
Indicates whether the associated view should be in
read-only
mode. Whentrue
, the associated view should display the form in a read-only mode, disabling any editing.- Default Value:false
-
editType
editType String
-
The type of edit operation the form is being used for. This can influence whether a field is editable or not (e.g., the layer only allows certain edit operations), and it is the value used for the
$editcontext.editType
variable when evaluating Arcade expressions. The value "NA" is always allowed when determining if a layer allows the current edit type.Possible Values:"INSERT" |"UPDATE" |"DELETE" |"NA"
- Default Value:"NA"
- See also
-
expressionEvaluationFailed
expressionEvaluationFailed Booleanreadonly
-
Indicates whether any of the Arcade expressions in the form have failed to evaluate.
-
features
features Collection<Graphic>
-
The collection of features whose attributes are being edited. This collection should be treated as immutable. Adding, removing, or re-ordering features is not allowed and may yield unexpected results. You can assign a new collection to this property, but this will cause the form inputs to be re-generated and any modified values to be discarded.
-
hasTooManyFeatures
hasTooManyFeatures Booleanreadonly
-
Indicates whether the form has too many features to be loaded.
-
hasVisibleInputs
hasVisibleInputs Booleanreadonly
-
Indicates whether there are any visible inputs in the form. This is
true
if there are any inputs that are visible to the user, meaning they are not hidden by a visibility expression or group visibility expression.
-
Returns an array of features that are invalid, meaning they have at least one invalid attribute value.
-
layers
layers Array<(FeatureLayer|GeoJSONLayer|SceneLayer|SubtypeSublayer|OrientedImageryLayer)>readonly
-
An array of layers included in the batch attribute form. Each layer must support feature editing and field access.
The following layer types are supported:
- FeatureLayer
- GeoJSONLayer
- SceneLayer (with
featureLayer
property) - SubtypeSublayer
- OrientedImageryLayer
-
A reference to the associated Map.
This property is required if working with Arcade expressions in the
BatchAttributeForm
that make use of the$map
global variable.
-
mode
mode Stringreadonly
-
The mode of the form, which can be either
"single"
or"batch"
. In"single"
mode, the form is editing a single feature at a time, while in"batch"
mode, it is editing all of the features in the features collection. To change the mode, set the activeFeatureIndex property.Possible Values:"single" |"batch"
- Default Value:"batch"
-
status
status Stringreadonly
-
Indicates whether the view model is ready to be used. Upon construction, and then again any time the
features
Collection is modified or re-assigned, the view model must perform certain asynchronous tasks in order to compile the shared attribute form. Use thestatus
property to determine when this processing occurs.Value Description not-loaded The features property has not been initialized or is an empty Collection. loading The features property has been set or modified, and the view model is compiling the shared form. Certain properties, like activeForm, should not be accessed yet. loaded The view model is ready to use. failed An error occurred while compiling the shared form. Possible Values:"not-loaded" |"loading" |"failed" |"loaded"
-
submitHasBeenAttempted
submitHasBeenAttempted Boolean
-
Indicates whether the user has attempted to submit the form.
- Default Value:false
-
The time zone used to interpret date values in the form. If this property is
null
or set to"unknown"
, date values are displayed in the time zone specified by the layer's preferredTimeZone. If none is provided there, date values are interpreted in UTC.
-
userHasChangedValues
userHasChangedValues Boolean
-
Indicates whether any values, for any features, have been modified by the user. This property does not take into account changes to attribute values that resulted from calculated value expressions.
- Default Value:false
-
valid
valid Booleanreadonly
-
Indicates whether there are any validation errors for any fields for any features.
-
visibleInputs
visibleInputs Array<(FieldInput|GroupInput)>readonly
-
An array of visible inputs in the active form. This is a subset of the inputs that are currently being edited, filtered to only include those that are visible to the user.
Method Overview
Name | Return Type | Summary | Class |
---|---|---|---|
Adds one or more handles which are to be tied to the lifecycle of the object. | Accessor | ||
Emits an event on the instance. | BatchAttributeFormViewModel | ||
Convenience method to find field inputs. | BatchAttributeFormViewModel | ||
The method used to get the updated field value. | BatchAttributeFormViewModel | ||
Indicates whether there is an event listener on the instance that matches the provided event name. | BatchAttributeFormViewModel | ||
Returns true if a named group of handles exist. | Accessor | ||
Registers an event handler on the instance. | BatchAttributeFormViewModel | ||
Removes a group of handles owned by the object. | Accessor | ||
This method triggers the | BatchAttributeFormViewModel |
Method Details
-
Inherited from Accessor
-
Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.
// Manually manage handles const handle = reactiveUtils.when( () => !view.updating, () => { wkidSelect.disabled = false; }, { once: true } ); this.addHandles(handle); // Destroy the object this.destroy();
ParametershandleOrHandles WatchHandle|WatchHandle[]Handles marked for removal once the object is destroyed.
groupKey *optionalKey identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.
-
Convenience method to find field inputs. Gets field inputs from the _activeFormInputsByElementId cache if there is one
Returns
-
The method used to get the updated field value.
ParameterelementId StringThe id of the target field where the value is accessed.
Returns
-
hasHandles
InheritedMethodhasHandles(groupKey){Boolean}
Inherited from Accessor -
Returns true if a named group of handles exist.
ParametergroupKey *optionalA group key.
ReturnsType Description Boolean Returns true
if a named group of handles exist.Example// Remove a named group of handles if they exist. if (obj.hasHandles("watch-view-updates")) { obj.removeHandles("watch-view-updates"); }
-
on
on(type, listener){Object}
-
Registers an event handler on the instance. Call this method to hook an event with a listener.
ParametersReturnsType Description Object Returns an event handler with a remove()
method that should be called to stop listening for the event(s).Property Type Description remove Function When called, removes the listener from the event. Exampleview.on("click", function(event){ // event is the event handle returned after the event fires. console.log(event.mapPoint); });
-
Inherited from Accessor
-
Removes a group of handles owned by the object.
ParametergroupKey *optionalA group key or an array or collection of group keys to remove.
Exampleobj.removeHandles(); // removes handles from default group obj.removeHandles("handle-group"); obj.removeHandles("other-handle-group");
-
This method triggers the
"submit"
event, and causes submitHasBeenAttempted to becometrue
. It does not do anything to persist the updated values. It is up to the client these values as appropriate — for example, by calling FeatureLayer.applyEdits() method to update the features' attributes.Example// Listen for when 'submit' is called on the form. // Once it is fired, update the feature. batchAttributeForm.on("submit", updateFeature); // When the DOM's button (btnUpdate) is clicked, // execute the 'submit()' method. on(dom.byId("btnUpdate"), "click", form.submit());
Type Definitions
-
SubmitResult
SubmitResult Object
-
Describes the state of a single feature's attribute values at the time of a form submission.
Event Overview
Name | Type | Summary | Class |
---|---|---|---|
|
{name: "submit",results: SubmitResult[],valid: Boolean} |
Fires when the submit() method is called. |
BatchAttributeFormViewModel |
|
{features: Graphic[],fieldName: String,name: "value-change",value: Number|String|null|undefined} |
Fires when field values are updated. |
BatchAttributeFormViewModel |
Event Details
-
Fires when the submit() method is called.
- Properties
-
name String
The name of the event.
The value is always "submit".
results SubmitResult[]An array containing a result object for each feature in the form.
valid BooleanIndicates whether the form is valid. This is
true
if all features in the form have valid attribute values, andfalse
if any feature has at least one invalid attribute value.
-
Fires when field values are updated.