<?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 Sketch Widget edit/select additional related graphics in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sketch-widget-edit-select-additional-related/m-p/1561523#M86125</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am using the sketch widget and it works fine so far.&lt;/P&gt;&lt;P&gt;In my app I have some figures/graphics, which are made from multiple graphics. Lets say on figure is made of 3 polylines and to points.&lt;/P&gt;&lt;P&gt;When having the sketch widget open I know could select either of these five graphics.&lt;/P&gt;&lt;P&gt;What I want is that if one of these graphics is selected I also want the others beeing selected to.&lt;BR /&gt;By this I achieve two important things:&lt;/P&gt;&lt;P&gt;first: if one selected graphic is moved, all related graphics are moved too&lt;/P&gt;&lt;P&gt;second: if one selected graphic is deleted, all related graphics get deleted too.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My (non-working) code so far looks like:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;export type MyGraphic = Graphic &amp;amp; {
    parent?: MyGraphic;
};

widget.on("update", e =&amp;gt; {
            if(e.state === "start" &amp;amp;&amp;amp; e.tool === "transform" &amp;amp;&amp;amp; e.type === "update") {
                const graphics = e.graphics;
                const allGraphicsToSelect: MyGraphic[] = [];
                graphics.forEach(graphic =&amp;gt; {
                    const myGraphic = graphic as MyGraphic;
                    if(!myGraphic.parent) {
                        allGraphicsToSelect.push(myGraphic);
                    } else {
                        const rootParent = this._myService.getRootParent(myGraphic);
                        const allChildren = this._myService.getMyChildsRecursivley(rootParent);
                        allGraphicsToSelect.push(rootParent);
                        allGraphicsToSelect.push(...allChildren);
                    }
                });
                //TODO selet/edit all allGraphicsToSelect
            }

            this._myService.handleSketchUpdateEventAsync(e);
        });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would appreciate any ideas for how to do so.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Thu, 21 Nov 2024 22:07:39 GMT</pubDate>
    <dc:creator>SebastianKrings</dc:creator>
    <dc:date>2024-11-21T22:07:39Z</dc:date>
    <item>
      <title>Sketch Widget edit/select additional related graphics</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sketch-widget-edit-select-additional-related/m-p/1561523#M86125</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am using the sketch widget and it works fine so far.&lt;/P&gt;&lt;P&gt;In my app I have some figures/graphics, which are made from multiple graphics. Lets say on figure is made of 3 polylines and to points.&lt;/P&gt;&lt;P&gt;When having the sketch widget open I know could select either of these five graphics.&lt;/P&gt;&lt;P&gt;What I want is that if one of these graphics is selected I also want the others beeing selected to.&lt;BR /&gt;By this I achieve two important things:&lt;/P&gt;&lt;P&gt;first: if one selected graphic is moved, all related graphics are moved too&lt;/P&gt;&lt;P&gt;second: if one selected graphic is deleted, all related graphics get deleted too.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My (non-working) code so far looks like:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;export type MyGraphic = Graphic &amp;amp; {
    parent?: MyGraphic;
};

widget.on("update", e =&amp;gt; {
            if(e.state === "start" &amp;amp;&amp;amp; e.tool === "transform" &amp;amp;&amp;amp; e.type === "update") {
                const graphics = e.graphics;
                const allGraphicsToSelect: MyGraphic[] = [];
                graphics.forEach(graphic =&amp;gt; {
                    const myGraphic = graphic as MyGraphic;
                    if(!myGraphic.parent) {
                        allGraphicsToSelect.push(myGraphic);
                    } else {
                        const rootParent = this._myService.getRootParent(myGraphic);
                        const allChildren = this._myService.getMyChildsRecursivley(rootParent);
                        allGraphicsToSelect.push(rootParent);
                        allGraphicsToSelect.push(...allChildren);
                    }
                });
                //TODO selet/edit all allGraphicsToSelect
            }

            this._myService.handleSketchUpdateEventAsync(e);
        });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would appreciate any ideas for how to do so.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2024 22:07:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sketch-widget-edit-select-additional-related/m-p/1561523#M86125</guid>
      <dc:creator>SebastianKrings</dc:creator>
      <dc:date>2024-11-21T22:07:39Z</dc:date>
    </item>
  </channel>
</rss>

