<?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: Toggle action at runtime in custom widget in ArcGIS Experience Builder Questions</title>
    <link>https://community.esri.com/t5/arcgis-experience-builder-questions/toggle-action-at-runtime-in-custom-widget/m-p/1556312#M15819</link>
    <description>&lt;P&gt;Hey Marc,&lt;/P&gt;&lt;P&gt;Here's a sample of what I did. Similar to FangQi's suggestion, I added a component in my widget intended to allow the user to change the widget behavior at runtime. As a user flips the Switch, I capture the current state and pass it up to the widget state to be used elsewhere in the application.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const UserOptions = (props: AllWidgetProps&amp;lt;IMConfig&amp;gt;) =&amp;gt; {
  const [isRotateImages, setIsRotateImages] = useState&amp;lt;boolean&amp;gt;(props.config.rotateImagesOnByDefault);

  useEffect(() =&amp;gt; {
    // to immediately handle changes when the settings panel is re-configured
    // and pass up this value to the parent widget on initial load
    setIsRotateImages(props.config.rotateImagesOnByDefault);
    props.dispatch(appActions.widgetStatePropChange(props.id, 'isRotateImages', props.config.rotateImagesOnByDefault));
  }, [props.config.rotateImagesOnByDefault]);

  const handleIsRotateImagesChange = (event: React.ChangeEvent&amp;lt;HTMLInputElement&amp;gt;) =&amp;gt; {
    setIsRotateImages(event.target.checked);
    props.dispatch(appActions.widgetStatePropChange(props.id, 'isRotateImages', event.target.checked));
  };

  const style = getStyle(props);
  return (
    &amp;lt;div css={style}&amp;gt;
      &amp;lt;div className="action-bar"&amp;gt;
        &amp;lt;div className="options-header"&amp;gt;User Options&amp;lt;/div&amp;gt;
        &amp;lt;div&amp;gt;
          &amp;lt;Switch
            checked={isRotateImages}
            onChange={handleIsRotateImagesChange}
          /&amp;gt;
          &amp;lt;Label className="option-label"&amp;gt;Rotate Images&amp;lt;/Label&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Nov 2024 15:22:48 GMT</pubDate>
    <dc:creator>JarrettGreen</dc:creator>
    <dc:date>2024-11-07T15:22:48Z</dc:date>
    <item>
      <title>Toggle action at runtime in custom widget</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/toggle-action-at-runtime-in-custom-widget/m-p/1554483#M15755</link>
      <description>&lt;P&gt;I have a custom widget that uses the zoom to features when my data filtering changes, but sometimes I want to disable this zooming at runtime.&amp;nbsp; How do I allow users to toggle this off and on?&amp;nbsp; Do I save the action for my particular widgetId and then remove it from the list of actions (no disable/.enable property?)&amp;nbsp; and then add it back if they want the zooming functionality back?&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;DataActionManager.&lt;SPAN&gt;getInstance&lt;/SPAN&gt;().&lt;SPAN&gt;getActions&lt;/SPAN&gt;()&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 31 Oct 2024 19:28:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/toggle-action-at-runtime-in-custom-widget/m-p/1554483#M15755</guid>
      <dc:creator>MarcBateEA</dc:creator>
      <dc:date>2024-10-31T19:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle action at runtime in custom widget</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/toggle-action-at-runtime-in-custom-widget/m-p/1554982#M15773</link>
      <description>&lt;P&gt;Hi Marc,&lt;/P&gt;&lt;P&gt;I think maybe you can try to put a toggle option in your custom widget like 'Enable/Disable Zoom to' and save the option in something like the 'mutableStore' or 'appRuntimeInfo'. Make sure your widget listens to the changes of the&amp;nbsp;'mutableStore' or 'appRuntimeInfo'.&lt;/P&gt;&lt;P&gt;After doing this, try to add this option in your action's 'isSupported' checking logic. In this way you can let the end users toggle the action on/off at runtime.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Nov 2024 02:26:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/toggle-action-at-runtime-in-custom-widget/m-p/1554982#M15773</guid>
      <dc:creator>FangQi</dc:creator>
      <dc:date>2024-11-04T02:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle action at runtime in custom widget</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/toggle-action-at-runtime-in-custom-widget/m-p/1556312#M15819</link>
      <description>&lt;P&gt;Hey Marc,&lt;/P&gt;&lt;P&gt;Here's a sample of what I did. Similar to FangQi's suggestion, I added a component in my widget intended to allow the user to change the widget behavior at runtime. As a user flips the Switch, I capture the current state and pass it up to the widget state to be used elsewhere in the application.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const UserOptions = (props: AllWidgetProps&amp;lt;IMConfig&amp;gt;) =&amp;gt; {
  const [isRotateImages, setIsRotateImages] = useState&amp;lt;boolean&amp;gt;(props.config.rotateImagesOnByDefault);

  useEffect(() =&amp;gt; {
    // to immediately handle changes when the settings panel is re-configured
    // and pass up this value to the parent widget on initial load
    setIsRotateImages(props.config.rotateImagesOnByDefault);
    props.dispatch(appActions.widgetStatePropChange(props.id, 'isRotateImages', props.config.rotateImagesOnByDefault));
  }, [props.config.rotateImagesOnByDefault]);

  const handleIsRotateImagesChange = (event: React.ChangeEvent&amp;lt;HTMLInputElement&amp;gt;) =&amp;gt; {
    setIsRotateImages(event.target.checked);
    props.dispatch(appActions.widgetStatePropChange(props.id, 'isRotateImages', event.target.checked));
  };

  const style = getStyle(props);
  return (
    &amp;lt;div css={style}&amp;gt;
      &amp;lt;div className="action-bar"&amp;gt;
        &amp;lt;div className="options-header"&amp;gt;User Options&amp;lt;/div&amp;gt;
        &amp;lt;div&amp;gt;
          &amp;lt;Switch
            checked={isRotateImages}
            onChange={handleIsRotateImagesChange}
          /&amp;gt;
          &amp;lt;Label className="option-label"&amp;gt;Rotate Images&amp;lt;/Label&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 15:22:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/toggle-action-at-runtime-in-custom-widget/m-p/1556312#M15819</guid>
      <dc:creator>JarrettGreen</dc:creator>
      <dc:date>2024-11-07T15:22:48Z</dc:date>
    </item>
  </channel>
</rss>

