require(["esri/layers/support/Field"], function(Field) { /* code goes here */ });
Class: esri/layers/support/Field
Inheritance: Field Accessor
Since: ArcGIS API for JavaScript 4.0

Information about each field in a layer. Field objects must be constructed when creating a FeatureLayer from client-side graphics. This class allows you to define the schema of each field in the FeatureLayer. Note that you do not need to add fields to the constructor of a FeatureLayer loaded from a service since they are already defined by the service. See the sample below for more information about using this module.

See also:
Example:
// Each object in this array is autocast as
// an instance of esri/layers/support/Field
var fields = [
  {
    name: "ObjectID",
    alias: "ObjectID",
    type: "oid"
  }, {
    name: "title",
    alias: "title",
    type: "string"
  }, {
    name: "type",
    alias: "type",
    type: "string"
  }, {
    name: "mag",
    alias: "Magnitude",
    type: "double"
}];

// add the array of fields to a feature layer
// created from client-side graphics
featureLayer.set({
  fields: fields,
  objectIdField: "ObjectID"
});

Constructors

new Field(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 Working with Properties topic.
NameTypeSummary
String

The alias name for the field.

more details
more details
String

The name of the class.

more details
more details
Domain

The domain associated with the field.

more details
more details
Boolean

Indicates whether the field is editable.

more details
more details
Number

The field length.

more details
more details
String

The name of the field.

more details
more details
Boolean

Indicates if the field can accept null values.

more details
more details
String

The data type of the field.

more details
more details

Property Details

aliasString

The alias name for the field.

declaredClassStringreadonly

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

domainDomain

The domain associated with the field.

editableBoolean

Indicates whether the field is editable.

lengthNumber

The field length.

nameString

The name of the field.

nullableBoolean

Indicates if the field can accept null values. Requires ArcGIS Server version 10.1 or greater.

typeString

The data type of the field.

Possible Values: small-integer | integer | single | double | string | date | oid | geometry | blob | raster | guid | global-id | xml

Method Overview

NameReturn TypeSummary
*

Creates a new instance of this class and initializes it with values from a JSON object generated from a product in the ArcGIS platform.

more details
more details
Object

Converts an instance of this class to its ArcGIS Portal JSON representation.

more details
more details

Method Details

fromJSON(json){*}static

Creates a new instance of this class and initializes it with values from a JSON object generated from a product in the ArcGIS platform. The object passed into the input json parameter often comes from a response to a query operation in the REST API or a toJSON() method from another ArcGIS product. See the Using fromJSON() topic in the Guide for details and examples of when and how to use this function.

Parameter:
json Object

A JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects.

Returns:
TypeDescription
*Returns a new instance of this class.

toJSON(){Object}

Converts an instance of this class to its ArcGIS Portal JSON representation. See the Using fromJSON() topic in the Guide for more information.

Returns:
TypeDescription
ObjectThe ArcGIS Portal JSON representation of an instance of this class.

API Reference search results

NameTypeModule

There were no match results from your search criteria.