Skip to content
import TableTemplate from "@arcgis/core/widgets/FeatureTable/support/TableTemplate.js";
Inheritance:
TableTemplateAccessor
Since
ArcGIS Maps SDK for JavaScript 4.24

A TableTemplate formats and defines the content of a FeatureTable.

The TableTemplate can be set directly on a FeatureTable or its view model. The template consists of various column templates that can be configured for both individual fields and grouped fields.

Considerations

This class differs from AttributeTableTemplate. The TableTemplate provides more fine-grained control over how the table is rendered within the application by offering more advanced configurations such as custom cell rendering, column formatting, and more. TableTemplate is useful for application-level development that remains within an application. Use AttributeTableTemplate to access the table's settings across different applications. By using this, the table's column settings can be saved within a webmap or layer. Please refer to the AttributeTableTemplate documentation for more information.

The FeatureTable prioritizes the table's configurations in the following order:

  1. The TableTemplate defined in the FeatureTable.
  2. The FeatureTable.attributeTableTemplate defined in the FeatureTable.
  3. The AttributeTableTemplate defined in the layer or standalone table.
  4. Default columns are generated based on the layer's fields if no table templates exist.
Example
const tableTemplate = new TableTemplate({
columnTemplates: [ // takes an array of FieldColumnTemplate and GroupColumnTemplate
{ // autocasts to FieldColumnTemplate
type: "field",
fieldName: "ObjectId",
direction: "asc", // In order to use initialSortPriority, make sure direction is set
initialSortPriority: 1 // This field's sort order takes the second-highest priority.
},
{
type: "field",
fieldName: "NAME",
label: "Name",
direction: "asc", // In order to use initialSortPriority, make sure direction is set
initialSortPriority: 0 // This field's sort order takes the highest priority
},
{
type: "field",
fieldName: "STATUS",
label: "Status",
direction: "asc", // In order to use initialSortPriority, make sure direction is set
initialSortPriority: 2 // This field's sort order is prioritized after Name and ObjectId, respectively.
}]
});

Constructors

Constructor

Constructor
Parameters
ParameterTypeDescriptionRequired
properties
See the properties table for a list of all the properties that may be passed into the constructor.

Properties

Any properties can be set, retrieved or listened to. See the Watch for changes topic.
PropertyTypeClass
declaredClass
readonly inherited

columnTemplates

autocast Property
Type
SupportedColumnTemplates[]

A collection of field column templates and/or group column templates that represent an ordered list of column templates.

Column templates are designed to allow the developer the ability to define the structure for columns within the FeatureTable widget.

See also
Example
const tableTemplate = new TableTemplate({
columnTemplates: [
{ // autocasts to FieldColumnTemplate
type: "field",
fieldName: "ObjectId",
direction: "asc",
initialSortPriority: 1 // This field's sort order takes the second-highest priority.
},
{
type: "field",
fieldName: "NAME",
label: "Name",
initialSortPriority: 0 // This field's sort order takes the highest priority
},
{
type: "field",
fieldName: "STATUS",
label: "Status",
direction: "asc",
initialSortPriority: 2 // This field's sort order is prioritized after Name and ObjectId, respectively.
}]
});

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor

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

Methods

MethodSignatureClass
fromJSON
inherited static
fromJSON(json: any): any
clone
inherited
clone(): this
toJSON
inherited
toJSON(): any

fromJSON

inheritedstatic Method
Signature
fromJSON (json: any): any
Inherited from: JSONSupportMixin

Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product. 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.

Parameters
ParameterTypeDescriptionRequired
json
any

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
any

Returns a new instance of this class.

clone

inherited Method
Signature
clone (): this
Inherited from: ClonableMixin

Creates a deep clone of this object. Any properties that store values by reference will be assigned copies of the referenced values on the cloned instance.

Returns
this

A deep clone of the class instance that invoked this method.

toJSON

inherited Method
Signature
toJSON (): any
Inherited from: JSONSupportMixin

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

Returns
any

The ArcGIS portal JSON representation of an instance of this class.