<?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 (SOLVED) Undomanager did not remove graphics when undo() in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/undomanager-did-not-remove-graphics-when-undo/m-p/397131#M36603</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I figure it out.. finally&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;what I should have done is use the addedGraphics parameter instead of addedGraphic&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
 if(task=="add"){
&amp;nbsp; featureLayer.applyEdits([graphic], null, null, function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; operation = new esri.dijit.editing.Add({
&amp;nbsp;&amp;nbsp;&amp;nbsp; featureLayer: featureLayer,
&amp;nbsp;&amp;nbsp;&amp;nbsp; addedGraphics: [graphic]
&amp;nbsp;&amp;nbsp; });
&amp;nbsp; });

 }

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think this is a bug because when I read into the performUndo() code&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
 alert(undoManager.peekUndo().performUndo) //not performUndo().. This will execute the function and won't display the inline code in alert

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;the alert shows &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
 function(){ this._featureLayer.applyEdit(null, null, this._addedGraphics); }
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;when use addedGraphic: graphic&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
 alert(undoManager.peekUndo()._addedGraphic);
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;returns undefined, which means that addedGraphic did not get pushed into _addedGraphics.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 18:09:47 GMT</pubDate>
    <dc:creator>AllenHuang</dc:creator>
    <dc:date>2021-12-11T18:09:47Z</dc:date>
    <item>
      <title>Undomanager did not remove graphics when undo()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/undomanager-did-not-remove-graphics-when-undo/m-p/397130#M36602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;My attempted on using the UndoManager has been unsuccessful for a couple days and I'm stuck.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I did not setup a proxy.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I create a FeatureLayer object in memory with &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
 var drawingPointLayer = new esri.layers.FeatureLayer(featureCollection, {
&amp;nbsp; id: "drawPointLayer",
&amp;nbsp; mode: esri.layers.FeatureLayer.MODE_ONDEMAND
 });
 mapApp.map.addLayer(drawingPointLayer);
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;created UndoManager and button to perfom undo redo actions&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
 undoManager = new esri.UndoManager({maxOperations:50});

 var undoButton = new dijit.form.ToggleButton({
&amp;nbsp; id: "undoButton",
&amp;nbsp; showLabel: false,
&amp;nbsp; iconClass: "dijitEditorIcon dijitEditorIconUndo",
&amp;nbsp; onClick: function(){ 
&amp;nbsp;&amp;nbsp; undoManager.undo(); 
&amp;nbsp;&amp;nbsp; checkUndoRedoState(); 
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; mapApp.map.graphics.graphics.splice(mapApp.map.graphics.graphics.length-1, 1);
&amp;nbsp;&amp;nbsp; mapApp.map.graphics.redraw();
&amp;nbsp;&amp;nbsp; alert(undoManager.length + " | " + mapApp.map.graphics.graphics.length);
&amp;nbsp; }
 }, "undoButton");
 var redoButton = new dijit.form.Button({
&amp;nbsp; id: "redoButton",
&amp;nbsp; showLabel: false,
&amp;nbsp; iconClass: "dijitEditorIcon dijitEditorIconRedo",
&amp;nbsp; onClick: function(){ 
&amp;nbsp;&amp;nbsp; undoManager.redo(); 
&amp;nbsp;&amp;nbsp; checkUndoRedoState(); 
&amp;nbsp; }
 }, "redoButton");
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and add operation to UndoManager&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
function addToUndoManager(graphic, task){
 var operation;
 var featureLayer = mapApp.map.getLayer("drawPointLayer");
 //var featureLayer = mapApp.map.getLayer("landuseLayer");

 if(task=="add"){
&amp;nbsp; featureLayer.applyEdits([graphic], null, null, function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; operation = new esri.dijit.editing.Add({
&amp;nbsp;&amp;nbsp;&amp;nbsp; featureLayer: featureLayer,
&amp;nbsp;&amp;nbsp;&amp;nbsp; addedGraphic: graphic
&amp;nbsp;&amp;nbsp; });
&amp;nbsp; });

 }

 if(operation)
&amp;nbsp; undoManager.add(operation);
&amp;nbsp; 
 checkUndoRedoState();
 
 alert(undoManager.canUndo + " | " + undoManager.canRedo + " | " + operation.label + " | " + operation.type + " | " + undoManager.length + " | " + mapApp.map.graphics.graphics.length);
}
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;New point markers would be added to the map via mouse click. Undomananger would register. But when I press the undo button, the graphics on the map would not disappear.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm clueless on what to do next to solve this problem. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please Help&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jul 2013 13:49:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/undomanager-did-not-remove-graphics-when-undo/m-p/397130#M36602</guid>
      <dc:creator>AllenHuang</dc:creator>
      <dc:date>2013-07-15T13:49:18Z</dc:date>
    </item>
    <item>
      <title>(SOLVED) Undomanager did not remove graphics when undo()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/undomanager-did-not-remove-graphics-when-undo/m-p/397131#M36603</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I figure it out.. finally&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;what I should have done is use the addedGraphics parameter instead of addedGraphic&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
 if(task=="add"){
&amp;nbsp; featureLayer.applyEdits([graphic], null, null, function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; operation = new esri.dijit.editing.Add({
&amp;nbsp;&amp;nbsp;&amp;nbsp; featureLayer: featureLayer,
&amp;nbsp;&amp;nbsp;&amp;nbsp; addedGraphics: [graphic]
&amp;nbsp;&amp;nbsp; });
&amp;nbsp; });

 }

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think this is a bug because when I read into the performUndo() code&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
 alert(undoManager.peekUndo().performUndo) //not performUndo().. This will execute the function and won't display the inline code in alert

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;the alert shows &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
 function(){ this._featureLayer.applyEdit(null, null, this._addedGraphics); }
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;when use addedGraphic: graphic&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
 alert(undoManager.peekUndo()._addedGraphic);
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;returns undefined, which means that addedGraphic did not get pushed into _addedGraphics.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:09:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/undomanager-did-not-remove-graphics-when-undo/m-p/397131#M36603</guid>
      <dc:creator>AllenHuang</dc:creator>
      <dc:date>2021-12-11T18:09:47Z</dc:date>
    </item>
  </channel>
</rss>

