<?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: Editing feature layer values from custom widget in ArcGIS Experience Builder Questions</title>
    <link>https://community.esri.com/t5/arcgis-experience-builder-questions/editing-feature-layer-values-from-custom-widget/m-p/1497406#M13297</link>
    <description>&lt;P&gt;Hi, I am doing something similar, have you found any solution?&lt;/P&gt;</description>
    <pubDate>Tue, 25 Jun 2024 23:27:25 GMT</pubDate>
    <dc:creator>Jesan90</dc:creator>
    <dc:date>2024-06-25T23:27:25Z</dc:date>
    <item>
      <title>Editing feature layer values from custom widget</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/editing-feature-layer-values-from-custom-widget/m-p/1410915#M12131</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I've been working on producing a custom widget which allows the user to use tick boxes to select images for a future use down the line. Currently I have the widget generate divs for each object with attachments and produce a number of tick boxes equivalent to attachments.&lt;/P&gt;&lt;P&gt;What I now want to do is be able to edit values in a given field using these tick boxes. There isn't an easy solution for my end goal so I'm intending to do it like one of these two methods:&lt;/P&gt;&lt;P&gt;Method 1 - Using an array like this [0,0,0]&lt;/P&gt;&lt;P&gt;In this method, if a user clicked the 2nd attachment tickbox I would like the value to update to 0,1,0&lt;/P&gt;&lt;P&gt;Method 2 - Creating an array like this [1,3]&lt;/P&gt;&lt;P&gt;In this method, the values are added as shown above when the user clicks box 1 and box 3.&lt;/P&gt;&lt;P&gt;I'm not sure how to go about editing the values. Below is my current code for generating the data render:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import { React, IMDataSourceInfo, DataSource, DataSourceManager, DataSourceStatus, FeatureLayerQueryParams, AllWidgetProps, DataSourceComponent } from 'jimu-core';
const { useState, useEffect, useRef } = React;

export default function Widget(props: AllWidgetProps&amp;lt;{}&amp;gt;){
  const [query, setQuery] = useState&amp;lt;FeatureLayerQueryParams&amp;gt;(null);
  const cityNameRef = useRef&amp;lt;HTMLInputElement&amp;gt;(null);

  useEffect(() =&amp;gt; {
    queryFunc();
  }, []);

  const isDsConfigured = () =&amp;gt; {
    if (props.useDataSources &amp;amp;&amp;amp;
      props.useDataSources.length === 1 &amp;amp;&amp;amp;
      props.useDataSources[0].fields &amp;amp;&amp;amp;
      props.useDataSources[0].fields.length === 1) {
      return true;
    }
    return false;
  }

  const queryFunc = () =&amp;gt; {
    if (!isDsConfigured()) {
      return;
    }
    const fieldName = props.useDataSources[0].fields[0];
    const w = cityNameRef.current &amp;amp;&amp;amp; cityNameRef.current.value ?
      `${fieldName} like '%${cityNameRef.current.value}%'` : '1=1';
    setQuery({
      where: w,
      outFields: ['*'],
      pageSize: 10
    });
  }

  // EDIT BELOW HERE

  const dataRender = (ds: DataSource, info: IMDataSourceInfo) =&amp;gt; {
    const areaCommentsName = 'Comments'; 
    const objectIdFieldName = 'OBJECTID';
    const attachmentFieldName = 'attachment_count';
  
    const generateAttachmentCheckboxes = (count: number) =&amp;gt; {
      const checkboxes = [];
      for (let i = 0; i &amp;lt; count; i++) {
        checkboxes.push(&amp;lt;input type="checkbox" key={i} style={attachmentCheckboxStyle} /&amp;gt;);
      }
      return checkboxes;
    };
  
    return (
      &amp;lt;&amp;gt;
        &amp;lt;div className="record-list" style={recordListStyle}&amp;gt;
          {ds &amp;amp;&amp;amp; ds.getStatus() === DataSourceStatus.Loaded ? (
            ds.getRecords().map((r, i) =&amp;gt; {
              const objectIdValue = r.getData()[objectIdFieldName];
              const commentValue = r.getData()[areaCommentsName];
              const attachmentValue = r.getData()[attachmentFieldName];
              return (
                &amp;lt;div key={i} style={recordRowStyle}&amp;gt;
                  &amp;lt;div style={recordItemStylePoint}&amp;gt;&amp;lt;strong&amp;gt;Point:&amp;lt;/strong&amp;gt; {objectIdValue}&amp;lt;/div&amp;gt;
                  &amp;lt;div style={recordItemStyle}&amp;gt;&amp;lt;strong&amp;gt;Comment:&amp;lt;/strong&amp;gt; {commentValue}&amp;lt;/div&amp;gt;
                  &amp;lt;div style={recordItemStyle}&amp;gt;&amp;lt;strong&amp;gt;Photos to include:&amp;lt;/strong&amp;gt; {generateAttachmentCheckboxes(attachmentValue)}&amp;lt;/div&amp;gt;
                &amp;lt;/div&amp;gt;
              );
            })
          ) : null}
        &amp;lt;/div&amp;gt;
      &amp;lt;/&amp;gt;
    );
  };

  // EDIT ABOVE HERE


  if (!isDsConfigured()) {
    return &amp;lt;h3&amp;gt;
      &amp;lt;br /&amp;gt;
      Configure the data source.
    &amp;lt;/h3&amp;gt;;
  }
  return &amp;lt;div className="widget-use-feature-layer" style={{ width: '100%', height: '100%', maxHeight: '800px', overflow: 'auto' }}&amp;gt;

    &amp;lt;DataSourceComponent useDataSource={props.useDataSources[0]} query={query} widgetId={props.id} queryCount&amp;gt;
      {dataRender}
    &amp;lt;/DataSourceComponent&amp;gt;
  &amp;lt;/div&amp;gt;;
}
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Any guidance on this would be appreciated,&amp;nbsp; thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 13:56:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/editing-feature-layer-values-from-custom-widget/m-p/1410915#M12131</guid>
      <dc:creator>HarryBonshor-Mayes</dc:creator>
      <dc:date>2024-04-17T13:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: Editing feature layer values from custom widget</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/editing-feature-layer-values-from-custom-widget/m-p/1497406#M13297</link>
      <description>&lt;P&gt;Hi, I am doing something similar, have you found any solution?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 23:27:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/editing-feature-layer-values-from-custom-widget/m-p/1497406#M13297</guid>
      <dc:creator>Jesan90</dc:creator>
      <dc:date>2024-06-25T23:27:25Z</dc:date>
    </item>
  </channel>
</rss>

