Types
import type { GroupByFunction, GroupByFunctionGrouping, GroupByType, Filter, FilterFilterName } from "@arcgis/core/widgets/FeatureTemplates/types.js";

Type definitions

GroupByFunction

Type definition
Type parameters
<T = any>
Since
ArcGIS Maps SDK for JavaScript 5.0

The function used when setting the FeatureTemplates.groupBy property. It is used to customize the grouping of template items. This can aid in managing various template items and how they display within the widget. This takes an object containing a template and a layer property.

Parameters

ParameterTypeDescriptionRequired
grouping

An object containing the properties referenced below.

Returns
object

Groups consist of a group key and label. These are shown in the UI. If both the key and label are identical, return a string. Otherwise, return an object with key/name properties. This gives finer control of the groups.

Examples
// This example shows using a function to check if
// the layer title contains the word 'military'. If so,
// return a group of items called "All Military Templates"
function customGroup(grouping) {
// Consolidate all military layers
if (grouping.layer.title.toLowerCase().indexOf("military") > -1) {
return "All Military Templates"
}
// Otherwise, group by layer title
return grouping.layer.title;
}
// Create the FeatureTemplates widget
templates = new FeatureTemplates({
container: "templatesDiv",
layers: layers,
groupBy: customGroup
});
// Group template items by layers.
// This function is as same as setting
// the groupBy property to "layer" option.
function groupByLayer (grouping) {
const group = {
key: grouping.layer,
name: grouping.layer.title
};
return group;
}
// Create the FeatureTemplates widget
const templates = new FeatureTemplates({
container: "templatesDiv",
layers: layers,
groupBy: groupByLayer
});

GroupByFunctionGrouping

Type definition
Since
ArcGIS Maps SDK for JavaScript 5.0

template

Property
Type
FeatureTemplate | SharedTemplateMetadata
Since
ArcGIS Maps SDK for JavaScript 5.0

FeatureTemplate associated with the layer.

layer

Property
Type
LayerWithFeatureTemplatesUnion
Since
ArcGIS Maps SDK for JavaScript 5.0

FeatureLayer instance referenced in FeatureTemplates.layers property.

GroupByType

Type definition
Since
ArcGIS Maps SDK for JavaScript 5.0
Type
"none" | "layer" | "geometry" | GroupByFunction

Filter

Type definition
Since
ArcGIS Maps SDK for JavaScript 5.0

The filter used when setting the FeatureTemplates.filterFunction property. It takes an object containing a name property of the template item and returns whether or not to include it.

Parameters

ParameterTypeDescriptionRequired
filterName

An object containing a name property.

Returns
boolean

Function is a predicate, to test each element of the array. Return true to keep item in the template widget, otherwise, false to remove it.

Example
// Filter and display templates only if their labels contain the word `Street`
function myFilterFunction(filter) {
let containsName = filter.label.includes("Street");
return containsName;
}
// Create the FeatureTemplates widget
templates = new FeatureTemplates({
container: "templatesDiv",
visibleElements: {
filter: false, // disable the default filter UI
}
layers: [featureLayer], // in this example, one layer is used
filterFunction: myFilterFunction
});

FilterFilterName

Type definition
Since
ArcGIS Maps SDK for JavaScript 5.0

label

Property
Type
string | null | undefined
Since
ArcGIS Maps SDK for JavaScript 5.0

The name of the template item to filter.