<?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: Accessing events for dynamically generated buttons on a grid with in a widget in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-events-for-dynamically-generated-buttons/m-p/83521#M7601</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;i just do this inside the row clicked event and it solves my issue&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;e.stopPropagation();
&amp;nbsp;&amp;nbsp; var item = this._searchGrid.getItem(e.rowIndex);
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; if(item == null){return;}
&amp;nbsp;&amp;nbsp; if(e.cell.index == 1 &amp;amp;&amp;amp; e.rowIndex == item.index[0])
&amp;nbsp;&amp;nbsp; {//remove item
&amp;nbsp;&amp;nbsp;&amp;nbsp; var graphic = this._searchGrid.store.getValue(item,'graphic');
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.RemoveDisplayItem(graphic);
&amp;nbsp;&amp;nbsp;&amp;nbsp; this._searchGrid.store.deleteItem(item);
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; else{
&amp;nbsp;&amp;nbsp;&amp;nbsp; //var item = this._searchGrid.getItem(e.rowIndex);
&amp;nbsp;&amp;nbsp;&amp;nbsp; var graphic = this._searchGrid.store.getValue(item,'graphic');
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.DisplayItem(graphic);
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.PublishItem(this._searchGrid.getItem(e.rowIndex).searchPrefix,this._searchGrid.getItem(e.rowIndex).value,graphic);
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 23:12:29 GMT</pubDate>
    <dc:creator>HaroldBostic</dc:creator>
    <dc:date>2021-12-10T23:12:29Z</dc:date>
    <item>
      <title>Accessing events for dynamically generated buttons on a grid with in a widget</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-events-for-dynamically-generated-buttons/m-p/83518#M7598</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello, I have a grid defined in my widget.&amp;nbsp; for each row, I have an image that I want to act as the remove button.&amp;nbsp; How do I set the html, so that I know when the button/image is clicked.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried variations of the commented and uncommented code in DeleteFormatter.&amp;nbsp;&amp;nbsp; Any help would be gladly appreciated&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's a subset of my class&lt;/SPAN&gt;&lt;PRE class="plain" name="code"&gt;startup: function() {
&amp;nbsp;&amp;nbsp; console.log("DisplaySearchGridWidget startup");
&amp;nbsp;&amp;nbsp; this.inherited(arguments);
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; //grid structure
&amp;nbsp;&amp;nbsp; var layout = {
&amp;nbsp;&amp;nbsp;&amp;nbsp; cells:[
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; field:"value",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name:"Results",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; width:'85%',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; height:'100%'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; },
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; field:"remove",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name:"Delete",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; width:'15%',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; height:'100%',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; formatter:this.DeleteFormater
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; ]
&amp;nbsp;&amp;nbsp; };
&amp;nbsp;&amp;nbsp; this._searchGrid.set("structure",layout);
&amp;nbsp;&amp;nbsp; dojo.connect(this._searchGrid,"onRowClick",dojo.hitch(this,this.RowClicked));
&amp;nbsp;&amp;nbsp; dojo.subscribe("displaySearchGridEvent",this,"DisplayCurrentSearch");
&amp;nbsp; },
&amp;nbsp; RowClicked : function(e){
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; var item = this._searchGrid.getItem(e.rowIndex);
&amp;nbsp;&amp;nbsp; var graphic = this._searchGrid.store.getValue(item,'graphic');
&amp;nbsp;&amp;nbsp; this.DisplayItem(graphic);
&amp;nbsp;&amp;nbsp; this.PublishItem(this._searchGrid.getItem(e.rowIndex).searchPrefix,this._searchGrid.getItem(e.rowIndex).value,graphic);
&amp;nbsp;&amp;nbsp; 
&amp;nbsp; },
&amp;nbsp; DeleteFormater: function (remove){
&amp;nbsp;&amp;nbsp; "&amp;lt;img src='../assets/images/icons/minimize.png' alt='Ring' 'width='16' height='16'&amp;gt;"
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; /*var delButton = "&amp;lt;div dojoType=\"dijit.form.Button\"&amp;gt;&amp;lt;img src=\"../assets/images/icons/minimize.png\"";
&amp;nbsp;&amp;nbsp;&amp;nbsp; delButton = delButton + " width=\"16\" height=\"16\"";
&amp;nbsp;&amp;nbsp;&amp;nbsp; delButton = delButton + " onClick=\"DeleteItem('"+remove+"')\"&amp;gt;&amp;lt;/div&amp;gt;";
&amp;nbsp;&amp;nbsp;&amp;nbsp; return delButton; */
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; var delButton = "&amp;lt;button type=\"button\" data-dojo-type=\"dijit.form.Button\" data-dojo-props=\"iconClass:'DeleteIcon'";
&amp;nbsp;&amp;nbsp;&amp;nbsp; delButton += "onClick:function(){dojo.publish('searchItemClicked', ["+ remove + "]);}\"&amp;gt;&amp;lt;/button&amp;gt;";
&amp;nbsp;&amp;nbsp;&amp;nbsp; return delButton;
&amp;nbsp;&amp;nbsp; 
&amp;nbsp; },&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Mar 2012 16:55:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-events-for-dynamically-generated-buttons/m-p/83518#M7598</guid>
      <dc:creator>HaroldBostic</dc:creator>
      <dc:date>2012-03-12T16:55:56Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing events for dynamically generated buttons on a grid with in a widget</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-events-for-dynamically-generated-buttons/m-p/83519#M7599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hello, I have a grid defined in my widget.&amp;nbsp; for each row, I have an image that I want to act as the remove button.&amp;nbsp; How do I set the html, so that I know when the button/image is clicked.&lt;BR /&gt;I've tried variations of the commented and uncommented code in DeleteFormatter.&amp;nbsp;&amp;nbsp; Any help would be gladly appreciated&lt;BR /&gt;&lt;BR /&gt;Here's a subset of my class&lt;PRE class="lia-code-sample line-numbers language-none"&gt;startup: function() {
&amp;nbsp;&amp;nbsp; console.log("DisplaySearchGridWidget startup");
&amp;nbsp;&amp;nbsp; this.inherited(arguments);
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; //grid structure
&amp;nbsp;&amp;nbsp; var layout = {
&amp;nbsp;&amp;nbsp;&amp;nbsp; cells:[
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; field:"value",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name:"Results",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; width:'85%',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; height:'100%'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; },
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; field:"remove",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name:"Delete",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; width:'15%',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; height:'100%',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; formatter:this.DeleteFormater
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; ]
&amp;nbsp;&amp;nbsp; };
&amp;nbsp;&amp;nbsp; this._searchGrid.set("structure",layout);
&amp;nbsp;&amp;nbsp; dojo.connect(this._searchGrid,"onRowClick",dojo.hitch(this,this.RowClicked));
&amp;nbsp;&amp;nbsp; dojo.subscribe("displaySearchGridEvent",this,"DisplayCurrentSearch");
&amp;nbsp; },
&amp;nbsp; RowClicked : function(e){
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; var item = this._searchGrid.getItem(e.rowIndex);
&amp;nbsp;&amp;nbsp; var graphic = this._searchGrid.store.getValue(item,'graphic');
&amp;nbsp;&amp;nbsp; this.DisplayItem(graphic);
&amp;nbsp;&amp;nbsp; this.PublishItem(this._searchGrid.getItem(e.rowIndex).searchPrefix,this._searchGrid.getItem(e.rowIndex).value,graphic);
&amp;nbsp;&amp;nbsp; 
&amp;nbsp; },
&amp;nbsp; DeleteFormater: function (remove){
&amp;nbsp;&amp;nbsp; "&amp;lt;img src='../assets/images/icons/minimize.png' alt='Ring' 'width='16' height='16'&amp;gt;"
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; /*var delButton = "&amp;lt;div dojoType=\"dijit.form.Button\"&amp;gt;&amp;lt;img src=\"../assets/images/icons/minimize.png\"";
&amp;nbsp;&amp;nbsp;&amp;nbsp; delButton = delButton + " width=\"16\" height=\"16\"";
&amp;nbsp;&amp;nbsp;&amp;nbsp; delButton = delButton + " onClick=\"DeleteItem('"+remove+"')\"&amp;gt;&amp;lt;/div&amp;gt;";
&amp;nbsp;&amp;nbsp;&amp;nbsp; return delButton; */
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; var delButton = "&amp;lt;button type=\"button\" data-dojo-type=\"dijit.form.Button\" data-dojo-props=\"iconClass:'DeleteIcon'";
&amp;nbsp;&amp;nbsp;&amp;nbsp; delButton += "onClick:function(){dojo.publish('searchItemClicked', ["+ remove + "]);}\"&amp;gt;&amp;lt;/button&amp;gt;";
&amp;nbsp;&amp;nbsp;&amp;nbsp; return delButton;
&amp;nbsp;&amp;nbsp; 
&amp;nbsp; },&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Adding formatter on datagrid th is the right choice. The basic idea is to dynamically create a button and passed rowid to its onclick function.&amp;nbsp; Here is the sample i did for POC a while ago. It is a modified version of one of the ESRI sample. Hope it helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:12:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-events-for-dynamically-generated-buttons/m-p/83519#M7599</guid>
      <dc:creator>HemingZhu</dc:creator>
      <dc:date>2021-12-10T23:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing events for dynamically generated buttons on a grid with in a widget</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-events-for-dynamically-generated-buttons/m-p/83520#M7600</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the response.......I do pass the id to my formatter function, I call it remove rather than id.&amp;nbsp; This all works well in the global context, however, I need this to work in my widget.&amp;nbsp; the button I make in the formatter is not aware of my dijits context, therefore my delete function never gets executed.&amp;nbsp; Do you have any ideas for that?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 25 Mar 2012 05:38:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-events-for-dynamically-generated-buttons/m-p/83520#M7600</guid>
      <dc:creator>HaroldBostic</dc:creator>
      <dc:date>2012-03-25T05:38:04Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing events for dynamically generated buttons on a grid with in a widget</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-events-for-dynamically-generated-buttons/m-p/83521#M7601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;i just do this inside the row clicked event and it solves my issue&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;e.stopPropagation();
&amp;nbsp;&amp;nbsp; var item = this._searchGrid.getItem(e.rowIndex);
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; if(item == null){return;}
&amp;nbsp;&amp;nbsp; if(e.cell.index == 1 &amp;amp;&amp;amp; e.rowIndex == item.index[0])
&amp;nbsp;&amp;nbsp; {//remove item
&amp;nbsp;&amp;nbsp;&amp;nbsp; var graphic = this._searchGrid.store.getValue(item,'graphic');
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.RemoveDisplayItem(graphic);
&amp;nbsp;&amp;nbsp;&amp;nbsp; this._searchGrid.store.deleteItem(item);
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; else{
&amp;nbsp;&amp;nbsp;&amp;nbsp; //var item = this._searchGrid.getItem(e.rowIndex);
&amp;nbsp;&amp;nbsp;&amp;nbsp; var graphic = this._searchGrid.store.getValue(item,'graphic');
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.DisplayItem(graphic);
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.PublishItem(this._searchGrid.getItem(e.rowIndex).searchPrefix,this._searchGrid.getItem(e.rowIndex).value,graphic);
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:12:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-events-for-dynamically-generated-buttons/m-p/83521#M7601</guid>
      <dc:creator>HaroldBostic</dc:creator>
      <dc:date>2021-12-10T23:12:29Z</dc:date>
    </item>
  </channel>
</rss>

