@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
149 lines (145 loc) • 7.52 kB
TypeScript
import type WebMap from "../../WebMap.js";
import type WebScene from "../../WebScene.js";
import type Collection from "../../core/Collection.js";
import type Layer from "../../layers/Layer.js";
import type Sublayer from "../../layers/support/Sublayer.js";
import type ListItem from "./ListItem.js";
import type { ReadonlyCollection } from "../../core/Collection.js";
import type { EventedAccessor } from "../../core/Evented.js";
import type { Action } from "../LayerList/types.js";
import type { ListItemModifier, State } from "./types.js";
export interface TableListViewModelProperties extends Partial<Pick<TableListViewModel, "checkPublishStatusEnabled" | "listItemCreatedFunction" | "listModeDisabled" | "map" | "tables">> {}
export interface TableListViewModelEvents {
/**
* Emitted when the user clicks an [action](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionButton/) or
* [action toggle](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionToggle/) in a table list.
* Use this event to run custom logic when a specific action is triggered.
*
* @see [@trigger-action](https://developers.arcgis.com/javascript/latest/references/core/widgets/TableList/TableListViewModel/#event-trigger-action)
*/
"trigger-action": TableListViewModelTriggerActionEvent;
}
/**
* The event object for the `trigger-action` event in the table list.
*
* @see [@trigger-action](https://developers.arcgis.com/javascript/latest/references/core/widgets/TableList/TableListViewModel/#event-trigger-action)
*/
export interface TableListViewModelTriggerActionEvent {
/** The action clicked by the user. */
action: Action;
/** An item associated with the action. */
item: ListItem;
}
/**
* Provides the logic for the [TableList](https://developers.arcgis.com/javascript/latest/references/core/widgets/TableList/) widget and [component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-table-list/).
*
* @since 4.17
* @see [TableList](https://developers.arcgis.com/javascript/latest/references/core/widgets/TableList/) widget
* @see [Table List component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-table-list/)
* @see [Programming patterns: Widget viewModel pattern](https://developers.arcgis.com/javascript/latest/programming-patterns/#widget-viewmodel-pattern)
* @example
* const tableList = new TableList({
* viewModel: { // autocasts as new TableListViewModel
* map: map // specify the map containing the tables
* }
* });
*/
export default class TableListViewModel extends EventedAccessor {
/**
* @deprecated
* Do not directly reference this property.
* Use EventNames and EventTypes helpers from \@arcgis/core/Evented
*/
"@eventTypes": TableListViewModelEvents;
constructor(properties?: TableListViewModelProperties);
/**
* Whether to provide an indication if a layer is being published in the
* [TableList](https://developers.arcgis.com/javascript/latest/references/core/widgets/TableList/). When a layer is publishing,
* a rotating square will appear to the right of the list item title.
* The [ListItem.publishing](https://developers.arcgis.com/javascript/latest/references/core/widgets/TableList/ListItem/#publishing) property
* will be `false` if `checkPublishStatusEnabled` is `false`.
*
* @default false
* @since 4.25
*/
accessor checkPublishStatusEnabled: boolean;
/**
* Specifies a function that accesses each [ListItem](https://developers.arcgis.com/javascript/latest/references/core/widgets/TableList/ListItem/).
* Each list item can be modified according to its modifiable properties. Actions can be added to
* [list items](https://developers.arcgis.com/javascript/latest/references/core/widgets/TableList/ListItem/) using the
* [ListItem.actionsSections](https://developers.arcgis.com/javascript/latest/references/core/widgets/TableList/ListItem/#actionsSections) property.
*/
accessor listItemCreatedFunction: ListItemModifier | null | undefined;
/**
* Specifies whether to ignore the [Layer.listMode](https://developers.arcgis.com/javascript/latest/references/core/layers/Layer/#listMode) property of the layers to display all tables.
* A common use case for `listModeDisabled` is when you want to use the [TableList](https://developers.arcgis.com/javascript/latest/references/core/widgets/TableList/) to manage and configure a tables's `listMode` value.
*
* @default false
* @since 4.30
* @see [Layer.listMode](https://developers.arcgis.com/javascript/latest/references/core/layers/Layer/#listMode)
*/
accessor listModeDisabled: boolean;
/**
* A reference to the [Map](https://developers.arcgis.com/javascript/latest/references/core/Map/) containing the tables. Set this property
* to access the underlying tables within the map.
*
* @see [Map.tables](https://developers.arcgis.com/javascript/latest/references/core/Map/#tables)
* @see [WebMap.tables](https://developers.arcgis.com/javascript/latest/references/core/WebMap/#tables)
* @example
* // FeatureLayer.isTable = true.
* Layer.fromPortalItem({
* // Loads a layer (table) from a portal item
* portalItem: { // autocasts new PortalItem()
* id: "add portal id item"
* }
* }).then(function(layer) {
* // Load the layer
* layer.load().then(function() {
* // Check if the layer is a table
* if (layer.isTable) {
* map.tables.add(layer);
* console.log(map.tables);
* }
* });
* });
*
* const tableList = new TableList({
* map: map // map contains tables collection
* });
*/
accessor map: WebMap | WebScene | null | undefined;
/**
* The view model's state.
*
* @default "disabled"
*/
get state(): State;
/** The collection of table [ListItem](https://developers.arcgis.com/javascript/latest/references/core/widgets/TableList/ListItem/)s displayed within the widget. */
get tableItems(): Collection<ListItem>;
/**
* A collection of [Layer](https://developers.arcgis.com/javascript/latest/references/core/layers/Layer/) instances that are tables.
*
* @since 4.32
* @example
* const tableList = new TableListViewModel({
* tables: tables
* });
*/
accessor tables: ReadonlyCollection<Layer | Sublayer> | null | undefined;
/**
* The total number of [tableItems](https://developers.arcgis.com/javascript/latest/references/core/widgets/TableList/TableListViewModel/#tableItems) in the list.
*
* @since 4.32
* @see [tableItems](https://developers.arcgis.com/javascript/latest/references/core/widgets/TableList/TableListViewModel/#tableItems)
* @see [ListItem](https://developers.arcgis.com/javascript/latest/references/core/widgets/TableList/ListItem/)
*/
get totalItems(): number;
/**
* Triggers the [@trigger-action](https://developers.arcgis.com/javascript/latest/references/core/widgets/TableList/TableListViewModel/#event-trigger-action) event and executes
* the given [action](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionButton/) or [action toggle](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionToggle/).
*
* @param action - The action to execute.
* @param item - An item associated with the action.
*/
triggerAction(action: Action, item: ListItem): void;
}