UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

134 lines (132 loc) 8.61 kB
import type { ClonableMixin } from "../../../core/Clonable.js"; import type { JSONSupport } from "../../../core/JSONSupport.js"; import type { AttachmentsColumnTemplateProperties } from "./AttachmentsColumnTemplate.js"; import type { ColumnTemplateProperties } from "./ColumnTemplate.js"; import type { FieldColumnTemplateProperties } from "./FieldColumnTemplate.js"; import type { GroupColumnTemplateProperties } from "./GroupColumnTemplate.js"; import type { RelationshipColumnTemplateProperties } from "./RelationshipColumnTemplate.js"; import type { SupportedColumnTemplates } from "./types.js"; export interface TableTemplateProperties { /** * A collection of [field column templates](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/FieldColumnTemplate/) and/or [group column templates](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/GroupColumnTemplate/) 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](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/) widget. * * @see [FieldColumnTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/FieldColumnTemplate/) * @see [GroupColumnTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/GroupColumnTemplate/) * @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. * }] * }); */ columnTemplates?: ((FieldColumnTemplateProperties & { type: "field"; }) | (GroupColumnTemplateProperties & { type: "group"; }) | (ColumnTemplateProperties & { type: "column"; }) | (AttachmentsColumnTemplateProperties & { type: "attachment"; }) | (RelationshipColumnTemplateProperties & { type: "relationship"; }))[]; } /** * A TableTemplate formats and defines the content of a [FeatureTable](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/). * * The TableTemplate can be set directly on a [FeatureTable](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/) or its [view model](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/FeatureTableViewModel/). The template consists of various [column templates](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/TableTemplate/#columnTemplates) that can be configured for both [individual fields](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/FieldColumnTemplate/) and [grouped fields](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/GroupColumnTemplate/). * * > [!WARNING] * > * > **Considerations** * > * > This class differs from [AttributeTableTemplate](https://developers.arcgis.com/javascript/latest/references/core/tables/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](https://developers.arcgis.com/javascript/latest/references/core/tables/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](https://developers.arcgis.com/javascript/latest/references/core/tables/AttributeTableTemplate/) documentation * > for more information. * > * > The [FeatureTable](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/) prioritizes the table's configurations in the following order: * > * > 1. The [TableTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/TableTemplate/) defined in the FeatureTable. * > 2. The [FeatureTable.attributeTableTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/#attributeTableTemplate) defined in the FeatureTable. * > 3. The [AttributeTableTemplate](https://developers.arcgis.com/javascript/latest/references/core/tables/AttributeTableTemplate/) defined in the layer or standalone table. * > 4. Default columns are generated based on the layer's fields if no table templates exist. * * @since 4.24 * @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. * }] * }); */ export default class TableTemplate extends TableTemplateSuperclass { constructor(properties?: TableTemplateProperties); /** * A collection of [field column templates](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/FieldColumnTemplate/) and/or [group column templates](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/GroupColumnTemplate/) 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](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/) widget. * * @see [FieldColumnTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/FieldColumnTemplate/) * @see [GroupColumnTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/GroupColumnTemplate/) * @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. * }] * }); */ get columnTemplates(): SupportedColumnTemplates[]; set columnTemplates(value: ((FieldColumnTemplateProperties & { type: "field"; }) | (GroupColumnTemplateProperties & { type: "group"; }) | (ColumnTemplateProperties & { type: "column"; }) | (AttachmentsColumnTemplateProperties & { type: "attachment"; }) | (RelationshipColumnTemplateProperties & { type: "relationship"; }))[]); } declare const TableTemplateSuperclass: typeof JSONSupport & typeof ClonableMixin