<?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 Re: Search Widget with Layer View filter in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-widget-with-layer-view-filter/m-p/1498482#M84943</link>
    <description>&lt;P&gt;Ok, you can do something like the following so that if you update the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#filter" target="_self"&gt;LayerView.filter&lt;/A&gt;, it will automatically update the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-LayerSearchSource.html#filter" target="_self"&gt;LayerSearchSource.filter&lt;/A&gt; as well:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function setupFilter(layerSearchSource, layerView) {
	if (layerView.filter) {
		layerSearchSource.filter = {
			where: layerView.filter.where,
			geometry: layerView.filter.geometry
		};

		layerView.filter.watch(["where", "geometry"], function(newValue, oldValue, propertyName, target) {
			if (propertyName == "where")
				layerSearchSource.filter.where = newValue;
			else if (propertyName == "geometry")
				layerSearchSource.filter.geometry = newValue;
		});
	} else
		layerSearchSource.filter = null;
}

layerView.watch("filter", function(newValue, oldValue, propertyName, target) {
	setupFilter(layerSearchSource, layerView);
});

setupFilter(layerSearchSource, layerView);&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 27 Jun 2024 17:53:59 GMT</pubDate>
    <dc:creator>JoelBennett</dc:creator>
    <dc:date>2024-06-27T17:53:59Z</dc:date>
    <item>
      <title>Search Widget with Layer View filter</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-widget-with-layer-view-filter/m-p/1497667#M84932</link>
      <description>&lt;P&gt;Hi Community,&lt;BR /&gt;&lt;BR /&gt;I have created a search widget with layer as a source, which works completely fine, but I have a feature to filter features of the layer and when we filter features on layer view, search widget still suggests all the options based on layer without filter. How can I achieve that.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Mani Jauhari&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2024 15:32:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-widget-with-layer-view-filter/m-p/1497667#M84932</guid>
      <dc:creator>jauhari_mani</dc:creator>
      <dc:date>2024-06-26T15:32:09Z</dc:date>
    </item>
    <item>
      <title>Re: Search Widget with Layer View filter</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-widget-with-layer-view-filter/m-p/1497960#M84935</link>
      <description>&lt;P&gt;Unfortunately, the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html" target="_self"&gt;Search&lt;/A&gt; widget doesn't take into account the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#filter" target="_self"&gt;LayerView.filter&lt;/A&gt; when executing queries when using a &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-LayerSearchSource" target="_self"&gt;LayerSearchSource&lt;/A&gt;.&amp;nbsp; However, the LayerSearchSource does have a &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-LayerSearchSource.html#filter" target="_self"&gt;filter&lt;/A&gt; property which you can use to duplicate at least some of the LayerView.filter's properties.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;layerSearchSource.filter = {
	where: layerView.filter.where,
	geometry: layerView.filter.geometry
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Fortunately, "where" and "geometry" are the most common properties, so that might be all you need.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2024 17:49:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-widget-with-layer-view-filter/m-p/1497960#M84935</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2024-06-27T17:49:34Z</dc:date>
    </item>
    <item>
      <title>Re: Search Widget with Layer View filter</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-widget-with-layer-view-filter/m-p/1498217#M84939</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/6522"&gt;@JoelBennett&lt;/a&gt;,&lt;BR /&gt;I have tried this way but the layerSearchSource filter captures the static value from layerView filter at the time of creation, it does not take any reference from layerView, so if I update filter of layerView in the lifetime it does not affects&amp;nbsp;layerSearchSource filter of search widget.&lt;BR /&gt;&lt;BR /&gt;Also, I tried to update search widget property whenever I change filter for layerView, in that I am getting error with sources is a read only property can not be modified.&lt;BR /&gt;And I wish not to destroy search widget and create new one whenever filter changes as that will not be good on UI and it also kills the DOM container when destroy is called.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Mani&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2024 12:45:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-widget-with-layer-view-filter/m-p/1498217#M84939</guid>
      <dc:creator>jauhari_mani</dc:creator>
      <dc:date>2024-06-27T12:45:13Z</dc:date>
    </item>
    <item>
      <title>Re: Search Widget with Layer View filter</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-widget-with-layer-view-filter/m-p/1498482#M84943</link>
      <description>&lt;P&gt;Ok, you can do something like the following so that if you update the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#filter" target="_self"&gt;LayerView.filter&lt;/A&gt;, it will automatically update the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-LayerSearchSource.html#filter" target="_self"&gt;LayerSearchSource.filter&lt;/A&gt; as well:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function setupFilter(layerSearchSource, layerView) {
	if (layerView.filter) {
		layerSearchSource.filter = {
			where: layerView.filter.where,
			geometry: layerView.filter.geometry
		};

		layerView.filter.watch(["where", "geometry"], function(newValue, oldValue, propertyName, target) {
			if (propertyName == "where")
				layerSearchSource.filter.where = newValue;
			else if (propertyName == "geometry")
				layerSearchSource.filter.geometry = newValue;
		});
	} else
		layerSearchSource.filter = null;
}

layerView.watch("filter", function(newValue, oldValue, propertyName, target) {
	setupFilter(layerSearchSource, layerView);
});

setupFilter(layerSearchSource, layerView);&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 27 Jun 2024 17:53:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-widget-with-layer-view-filter/m-p/1498482#M84943</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2024-06-27T17:53:59Z</dc:date>
    </item>
  </channel>
</rss>

