<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Editor WebComponent access viewModel.featureTemplatesViewModel.filterFunction in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/editor-webcomponent-access-viewmodel/m-p/1697415#M88375</link>
    <description>&lt;P&gt;Using the old way of the Editor Widget wir used a filter function to exclude specific layers from the "front-page" of the EditorWidget while keeping the ability to still edit features of these layers.&lt;/P&gt;&lt;P&gt;This is how we successfully did that:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    [...]
    this._activeEditor = new Editor({
        view: mapView,
        container: this.canvasId,
        layerInfos
    });

    this._activeEditor.when(() =&amp;gt; {
        this.setFeatureTemplatesFilterAsync();
    });
}

private async setFeatureTemplatesFilterAsync() {
    const excludedTitles = await this._schema.getLayerNamesFromKeysAsync([LshLayerKeysEnum.CavePolygons, LshLayerKeysEnum.RoutingPositions]) ?? [];

    this._activeEditor!.viewModel.featureTemplatesViewModel.filterFunction = (item) =&amp;gt; {
        return !excludedTitles.some(title =&amp;gt; item?.label?.startsWith(title));
    };
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Now after changing to new web component I am asking myseld how to set the filterFunction or how to access the viewModel.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;This is how it currently looks without setting the filterFunction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;arcgis-editor
    reference-element="my-map"
    [layerInfos]="layerInfos()"&amp;gt;
&amp;lt;/arcgis-editor&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Apr 2026 11:58:55 GMT</pubDate>
    <dc:creator>SebastianKrings</dc:creator>
    <dc:date>2026-04-21T11:58:55Z</dc:date>
    <item>
      <title>Editor WebComponent access viewModel.featureTemplatesViewModel.filterFunction</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/editor-webcomponent-access-viewmodel/m-p/1697415#M88375</link>
      <description>&lt;P&gt;Using the old way of the Editor Widget wir used a filter function to exclude specific layers from the "front-page" of the EditorWidget while keeping the ability to still edit features of these layers.&lt;/P&gt;&lt;P&gt;This is how we successfully did that:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    [...]
    this._activeEditor = new Editor({
        view: mapView,
        container: this.canvasId,
        layerInfos
    });

    this._activeEditor.when(() =&amp;gt; {
        this.setFeatureTemplatesFilterAsync();
    });
}

private async setFeatureTemplatesFilterAsync() {
    const excludedTitles = await this._schema.getLayerNamesFromKeysAsync([LshLayerKeysEnum.CavePolygons, LshLayerKeysEnum.RoutingPositions]) ?? [];

    this._activeEditor!.viewModel.featureTemplatesViewModel.filterFunction = (item) =&amp;gt; {
        return !excludedTitles.some(title =&amp;gt; item?.label?.startsWith(title));
    };
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Now after changing to new web component I am asking myseld how to set the filterFunction or how to access the viewModel.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;This is how it currently looks without setting the filterFunction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;arcgis-editor
    reference-element="my-map"
    [layerInfos]="layerInfos()"&amp;gt;
&amp;lt;/arcgis-editor&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2026 11:58:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/editor-webcomponent-access-viewmodel/m-p/1697415#M88375</guid>
      <dc:creator>SebastianKrings</dc:creator>
      <dc:date>2026-04-21T11:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: Editor WebComponent access viewModel.featureTemplatesViewModel.filterFunction</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/editor-webcomponent-access-viewmodel/m-p/1702749#M88441</link>
      <description>&lt;P&gt;I found a way to access it, but since the Editor-Type is still deprecated I guess this is not a good long-term way.&lt;BR /&gt;&lt;BR /&gt;Any suggestions here?&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const editorElement = document.querySelector('arcgis-editor') as (HTMLElement &amp;amp; {
    componentOnReady?: () =&amp;gt; Promise&amp;lt;void&amp;gt;;
    widget?: Editor;
}) | null;

if (!editorElement) {
    return;
}

if (typeof editorElement.componentOnReady === 'function') {
    await editorElement.componentOnReady();
}

const editorWidget = editorElement.widget;
if (!editorWidget?.viewModel?.featureTemplatesViewModel) {
    return;
}

editorWidget.viewModel.featureTemplatesViewModel.filterFunction = item =&amp;gt; {
    return !excludedTitles.some(title =&amp;gt; item?.label?.startsWith(title));
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit: This Template Solution does not work, because, when creating one of these excluded Features via Relation of another non-excluded Feature, they are not selectable.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SebastianKrings_0-1779194735911.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/152626iFACB55CE4A5C03E9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SebastianKrings_0-1779194735911.png" alt="SebastianKrings_0-1779194735911.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SebastianKrings_1-1779194744992.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/152627iE25BD4B47C13CC19/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SebastianKrings_1-1779194744992.png" alt="SebastianKrings_1-1779194744992.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So the dirty DOM Solution is the one to choose.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;As an dirty alternative we also found another (more future reliable way) by DOM manipulation:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;/**
 * Observes the ArcGIS Editor shadow DOM for runtime UI updates.
 * The ArcGIS Editor dynamically rebuilds its internal DOM structure.
 * Therefore hidden create entries would reappear after rerendering
 * without a MutationObserver.
 * This observer listens for DOM changes and reapplies the
 * create-entry hiding logic whenever the editor updates itself.
 */
private observeEditorDom() {

	// Get the ArcGIS editor web component
	const editor = document.querySelector(
		'arcgis-editor'
	) as HTMLElement | null;

	// Abort if the shadow DOM is not available yet
	if (!editor?.shadowRoot) {
		return;
	}

	const root = editor.shadowRoot;

	// Reapply hiding logic whenever the editor rerenders
	const observer = new MutationObserver(() =&amp;gt; {
		this.hideConfiguredCreateEntriesAsync(root);
	});

	// Observe the complete editor subtree for changes
	observer.observe(root, {
		childList: true,
		subtree: true
	});

	// Initial execution after observer registration
	this.hideConfiguredCreateEntriesAsync(root);
}

/**
 * Hides configured layer create entries from the ArcGIS Editor UI.
 * Important:
 * - Only the visible UI entries are hidden
 * - Layers/templates remain fully functional internally
 * - Related feature creation therefore still works
 * The method only targets the "Create Features" section.
 * Related feature dialogs are ignored automatically because they
 * use a different DOM structure.
 * &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/891663"&gt;@Param&lt;/a&gt; root Shadow root of the ArcGIS Editor component
 */
private async hideConfiguredCreateEntriesAsync(root: ShadowRoot) {

	// Get currently active flow item inside the editor
	const selectedFlowItem = root.querySelector(
		'calcite-flow-item[selected]'
	) as HTMLElement | null;

	// Only the Create Features Section contains this container.
	// Related feature dialogs do not contain it.
	const createTemplatesContainer = selectedFlowItem?.querySelector(
		'.esri-editor__feature-templates-container'
	);

	// Abort if current view is not the create-features screen
	if (!selectedFlowItem || !createTemplatesContainer) {
		return;
	}

	// Resolve layer names dynamically via schema configuration
	const hiddenEntryNames =
		...) ?? [];

	// Collect all create-entry groups rendered by ArcGIS
	const groups = Array.from(
		createTemplatesContainer.querySelectorAll(
			'.esri-item-list__group'
		)
	).filter(
		(element): element is HTMLElement =&amp;gt;
			element instanceof HTMLElement
	);

	// Iterate through all rendered create groups
	for (const group of groups) {

		// Extract the visible heading text
		const groupHeading = group.querySelector(
			'.esri-widget__heading'
		);

		const groupHeadingText = groupHeading
			?.textContent
			?.trim();

		// Skip invalid entries
		if (!groupHeadingText) {
			continue;
		}

		// Check whether current group should be hidden
		const shouldHide = hiddenEntryNames.some(
			hiddenName =&amp;gt; groupHeadingText === hiddenName
		);

		// Skip unrelated or already hidden groups
		if (!shouldHide || group.dataset['createEntryHidden'] === 'true') {
			continue;
		}

		// Hide the complete create entry group
		group.style.display = 'none';

		// Mark as processed to avoid duplicate work
		group.dataset['createEntryHidden'] = 'true';
	}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 May 2026 12:46:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/editor-webcomponent-access-viewmodel/m-p/1702749#M88441</guid>
      <dc:creator>SebastianKrings</dc:creator>
      <dc:date>2026-05-19T12:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: Editor WebComponent access viewModel.featureTemplatesViewModel.filterFunction</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/editor-webcomponent-access-viewmodel/m-p/1702761#M88442</link>
      <description>&lt;P&gt;I not heard that another colleague had already contact to some Devs from ESRI and they are on it to add a top level option to achieve this. Til then we simply use the dirty workaround.&lt;/P&gt;</description>
      <pubDate>Tue, 19 May 2026 12:47:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/editor-webcomponent-access-viewmodel/m-p/1702761#M88442</guid>
      <dc:creator>SebastianKrings</dc:creator>
      <dc:date>2026-05-19T12:47:19Z</dc:date>
    </item>
  </channel>
</rss>

