BatchAttributeFormViewModel

ESM: import BatchAttributeFormViewModel from "@arcgis/core/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js";
CDN: const BatchAttributeFormViewModel = await $arcgis.import("@arcgis/core/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js");
Class: @arcgis/core/widgets/BatchAttributeForm/BatchAttributeFormViewModel
Inheritance: BatchAttributeFormViewModelAccessor
Since: ArcGIS Maps SDK for JavaScript 4.33

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
Example
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

BatchAttributeFormViewModel

Constructor
new BatchAttributeFormViewModel(properties)
Parameter
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Watch for changes topic.
Show inherited properties Hide inherited properties
Name Type Summary Class

The active feature in the form, which is the feature that is currently being edited while in singlemode.

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 read-only mode.

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 "single" or "batch".

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

activeFeature

Property
activeFeature Graphic |null |undefinedreadonly

The active feature in the form, which is the feature that is currently being edited while in singlemode. If the mode is batch, this property will be null.

activeFeatureIndex

Property
activeFeatureIndex Number

The index of the active feature that is currently being edited. This will be -1 when mode is batch. To enter single mode, set this property to the index in the features array of the feature you wish to edit individually. To enter batch mode, set this property to -1.

Default Value:-1

activeForm

Property
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. If single, 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

Property
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.

declaredClass

Inherited
Property
declaredClass Stringreadonly
Inherited from Accessor

The name of the class. The declared class name is formatted as esri.folder.className.

disabled

Property
disabled Boolean

Indicates whether the associated view should be in read-only mode. When true, the associated view should display the form in a read-only mode, disabling any editing.

Default Value:false

editType

Property
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

Property
expressionEvaluationFailed Booleanreadonly

Indicates whether any of the Arcade expressions in the form have failed to evaluate.

features

Property
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.

hasTooManyComplexFeatures

Property
hasTooManyComplexFeatures Booleanreadonly

Indicates whether the form has too many features to be loaded with forms containing complex Arcade expressions.

hasTooManyFeatures

Property
hasTooManyFeatures Booleanreadonly

Indicates whether the form has too many features to be loaded.

hasVisibleInputs

Property
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.

invalidFeatures

Property
invalidFeatures Graphic[]readonly

Returns an array of features that are invalid, meaning they have at least one invalid attribute value.

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:

map

Property
map Map |null |undefined

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

Property
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"

readOnly

Property
readOnly Boolean

Indicates whether the form is in a read-only state. When true, the user cannot modify any attribute values in the form. This is different from disabled, which indicates whether the entire form is disabled, including any UI controls.

Default Value:false

status

Property
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 the status 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

Property
submitHasBeenAttempted Boolean

Indicates whether the user has attempted to submit the form.

Default Value:false

timeZone

Property
timeZone String |null |undefined

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

Property
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

Property
valid Booleanreadonly

Indicates whether there are any validation errors for any fields for any features.

visibleInputs

Property
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

Show inherited methods Hide inherited methods
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
FieldInput|null|undefined

Convenience method to find field inputs.

BatchAttributeFormViewModel
FieldInput|null|undefined

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 "submit" event, and causes submitHasBeenAttempted to become true.

BatchAttributeFormViewModel

Method Details

addHandles

Inherited
Method
addHandles(handleOrHandles, groupKey)
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();
Parameters
handleOrHandles WatchHandle|WatchHandle[]

Handles marked for removal once the object is destroyed.

groupKey *
optional

Key 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.

emit

Method
emit(type, event){Boolean}

Emits an event on the instance. This method should only be used when creating subclasses of this class.

Parameters
type String

The name of the event.

event Object
optional

The event payload.

Returns
Type Description
Boolean true if a listener was notified

findFieldInput

Method
findFieldInput(elementId){FieldInput |null |undefined}

Convenience method to find field inputs. Gets field inputs from the _activeFormInputsByElementId cache if there is one

Parameter
elementId String|null|undefined

The elementId of the input field to find.

Returns
Type Description
FieldInput | null | undefined Returns an instance of the FieldInput.

getFieldInputValue

Method
getFieldInputValue(elementId){FieldInput |null |undefined}

The method used to get the updated field value.

Parameter
elementId String

The id of the target field where the value is accessed.

Returns
Type Description
FieldInput | null | undefined Returns the associated field value, or undefined if there is no matching attribute.

hasEventListener

Method
hasEventListener(type){Boolean}

Indicates whether there is an event listener on the instance that matches the provided event name.

Parameter
type String

The name of the event.

Returns
Type Description
Boolean Returns true if the class supports the input event.

hasHandles

Inherited
Method
hasHandles(groupKey){Boolean}
Inherited from Accessor

Returns true if a named group of handles exist.

Parameter
groupKey *
optional

A group key.

Returns
Type 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

Method
on(type, listener){Object}

Registers an event handler on the instance. Call this method to hook an event with a listener.

Parameters

An event or an array of events to listen for.

listener Function

The function to call when the event fires.

Returns
Type 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.
Example
view.on("click", function(event){
  // event is the event handle returned after the event fires.
  console.log(event.mapPoint);
});

removeHandles

Inherited
Method
removeHandles(groupKey)
Inherited from Accessor

Removes a group of handles owned by the object.

Parameter
groupKey *
optional

A group key or an array or collection of group keys to remove.

Example
obj.removeHandles(); // removes handles from default group

obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");

submit

Method
submit()

This method triggers the "submit" event, and causes submitHasBeenAttempted to become true. 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

Type Definition
SubmitResult Object

Describes the state of a single feature's attribute values at the time of a form submission.

Properties
feature Graphic

The feature described by this result object.

invalidFields String[]

The names of fields that have invalid values for this feature.

values Boolean

The updated attribute values for the feature.

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

submit

Event
submit

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 Boolean

Indicates whether the form is valid. This is true if all features in the form have valid attribute values, and false if any feature has at least one invalid attribute value.

value-change

Event
value-change

Fires when field values are updated.

Properties
features Graphic[]

The features affected by the value change.

fieldName String

The name of the field that was changed.

name String

The name of the event.

The value is always "value-change".

The updated field value.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.