UNPKG

@arcgis/core

Version:

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

139 lines (137 loc) 11.1 kB
import type CSVLayer from "../../layers/CSVLayer.js"; import type FeatureLayer from "../../layers/FeatureLayer.js"; import type GeoJSONLayer from "../../layers/GeoJSONLayer.js"; import type ImageryLayer from "../../layers/ImageryLayer.js"; import type SceneLayer from "../../layers/SceneLayer.js"; import type WFSLayer from "../../layers/WFSLayer.js"; import type CatalogFootprintLayer from "../../layers/catalog/CatalogFootprintLayer.js"; import type KnowledgeGraphSublayer from "../../layers/knowledgeGraph/KnowledgeGraphSublayer.js"; import type Field from "../../layers/support/Field.js"; import type EditorColumn from "./Grid/EditorColumn.js"; import type FieldColumnTemplate from "./support/FieldColumnTemplate.js"; import type { MapViewOrSceneView } from "../../views/MapViewOrSceneView.js"; import type { EditorColumnProperties } from "./Grid/EditorColumn.js"; import type { FieldValueFormatFunction } from "./support/types.js"; import type { FieldProperties } from "../../layers/support/Field.js"; export interface FieldColumnProperties extends EditorColumnProperties, Partial<Pick<FieldColumn, "editable" | "layer" | "required" | "template" | "view">> { /** The [Field](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Field/) associated with this column. */ field?: FieldProperties; /** * Indicates whether the column is sortable. * * @default true */ sortable?: boolean; } /** * The [FieldColumn](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/FieldColumn/) class works * with the [FeatureTable](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/) and provides the underlying * logic for column behavior. * * > [!WARNING] * > * > This class should be used for observing potential changes. Any configuration and changes to the field columns should be done handled via the [TableTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/TableTemplate/) and the [FieldColumnTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/FieldColumnTemplate/) class. * * @since 4.16 * @see [FeatureTable](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/) * @see [FeatureTableViewModel](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/FeatureTableViewModel/) * @see [FieldColumnTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/FieldColumnTemplate/) * @see [Field](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Field/) */ export default class FieldColumn extends EditorColumn { constructor(properties?: FieldColumnProperties); /** The display name for the field. */ get alias(): string | null | undefined; /** The default value set for the field. */ get defaultValue(): number | string | null | undefined; /** * Indicates whether the field is editable. Editing permissions can be broken down * with the following levels of priority: * * 1. [Field](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Field/) - This is derived * from the [FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/) or [SceneLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/SceneLayer/). It takes what is set in the * [Field.editable](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Field/#editable) property. This * must always be `true` for editing to be enabled. This can be overridden using a * [field column template](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/FieldColumnTemplate/). * 2. [Template](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/FieldColumnTemplate/) - The editable * permissions on a field can be configured by setting the * [FieldColumnTemplate.editable](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/FieldColumnTemplate/#editable) property * of the [FieldColumnTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/FieldColumnTemplate/). * 3. [FeatureTable](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/) - The [FeatureTable.editingEnabled](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/#editingEnabled) * property must be set on the table in order for any type of editing to be enabled. * * For example, if table editing is disabled in the widget, i.e. `enableEditing` is not set, * it is still possible to enable editing for a specific column by setting the * [FieldColumnTemplate.editable](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/FieldColumnTemplate/#editable) property. Vice versa * is also true, if table editing is enabled, a field template can be used to disable editing for a specific column. * * > [!WARNING] * > * > Ultimately, if the service's field is not editable, it is not possible to override its permissions * > using one of the options above. * * @see [FieldColumnTemplate.editable](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/FieldColumnTemplate/#editable) */ editable: boolean; /** * The sanitized [description](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/FieldColumn/#description), describing the purpose of each column. This takes into account the optional values of both [the columns's template description](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/ColumnTemplateBase/#description) and the value of the [field's description](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Field/#description). The template description takes precedence over the field's description as to allow for customizing the column's description. * * @since 4.31 * @see [ColumnTemplateBase.description](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/ColumnTemplateBase/#description) * @see [Field.description](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Field/#description) */ get effectiveDescription(): string | null | undefined; /** The [Field](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Field/) associated with this column. */ get field(): Field; set field(value: FieldProperties); /** * Custom function for rendering cell content that is called when the column is rendered in the table. The function should return the formatted content to display within a table's cell. This can be a string, number, an HTML element, or equivalent node type (e.g. a [Calcite component](https://developers.arcgis.com/calcite-design-system/components/)). If the content is an HTML element, it is appended to the root element. If the content is a string or number, it is set as the innerHTML of the root element. If the content is `null`, the root element is cleared. If the content is `undefined`, the root element is not modified. This property is useful when you want to customize the cell content. For example, you can use this property to create a custom cell renderer that displays a progress bar in the cell. The progress bar can be used to show the progress of a task. * * @example * // The following example demonstrates how to use the formatFunction property to create a custom cell renderer that displays a progress bar in the cell. The progress bar can be used to show the progress of a task. * column.formatFunction = ({ column, feature, index, value })=> { * const progress = document.createElement("progress"); * progress.max = 100; * progress.value = value; * return progress; * }; */ get formatFunction(): FieldValueFormatFunction | null | undefined; /** * The associated [CatalogFootprintLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/catalog/CatalogFootprintLayer/), [CSVLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/CSVLayer/), [FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/), [GeoJSONLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/), [ImageryLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/ImageryLayer/), * [KnowledgeGraphSublayer](https://developers.arcgis.com/javascript/latest/references/core/layers/knowledgeGraph/KnowledgeGraphSublayer/), [SceneLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/SceneLayer/), or [WFSLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/WFSLayer/) containing the fields and attributes to display within the widget. */ accessor layer: CatalogFootprintLayer | CSVLayer | FeatureLayer | GeoJSONLayer | ImageryLayer | KnowledgeGraphSublayer | SceneLayer | WFSLayer; /** Restricts the input length for the column. */ get maxLength(): number; /** Restricts the input length for the column. */ get minLength(): number | null | undefined; /** * The name of the field. * * @deprecated since version 4.30, use [fieldName](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/FieldColumn/#fieldName) instead. */ get name(): string | null | undefined; /** Indicates if the field can accept `null` values. */ get nullable(): boolean; /** Indicates whether a value is required when editing feature attributes within the table's cell. */ required: boolean; /** * Indicates whether the column is sortable. * * @default true */ accessor sortable: boolean; /** * A configurable template for the table column. The template allows for customizing the appearance of the column. Once the template is set, it will override the default appearance and will remain as such once the table is created. Any information regarding the column's current state can be accessed using the [Column](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/Grid/Column/) class. * * > [!WARNING] * > * > Templates should be used primarily for initial column configuration and should not be used for observing changes. * * @since 4.28 */ accessor template: FieldColumnTemplate | null | undefined; /** A reference to the [MapView](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/) or [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/). */ accessor view: MapViewOrSceneView | null | undefined; }