<?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: JavaScript Sample to widget in Web AppBuilder Custom Widgets Questions</title>
    <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/javascript-sample-to-widget/m-p/786889#M3688</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have the data in a deferred list and want to display it as items within the widget itself, I'd suggest creating a dom ID element in the widget.html file as Robert indicated above.&amp;nbsp; Then you could have the inidvidual items from the list within the widget.js file like the example I have below (from a tool I'm building), where I'm assigning a string value to a variable that then calls and sets the dom element:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;idstring = "Results: &amp;lt;br/&amp;gt;" +&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="line-height: 1.5;"&gt;"&amp;lt;br /&amp;gt;Number of Hospitals:&amp;nbsp; " + Hosp.length +&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; "&amp;lt;br /&amp;gt;Number of Medical Providers:&amp;nbsp; " + Med.length +&lt;/P&gt;&lt;P&gt;&amp;nbsp; "&amp;lt;br /&amp;gt;Number of Schools:&amp;nbsp; " + schools.length;&lt;/P&gt;&lt;P&gt;&amp;nbsp; dom.byId("results").innerHTML = idstring;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically, the widget.html file indicates what is shown on the screen and the widget.js is the underlying code for tasks that are performed by the widget.&amp;nbsp; Items within the html file are referred to as dom elements and can be referenced as shown in Robert's and my examples.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd suggest looking up this for more details:&amp;nbsp; &lt;A href="https://dojotoolkit.org/reference-guide/1.7/index.html" title="https://dojotoolkit.org/reference-guide/1.7/index.html"&gt;Dojo Toolkit Reference Guide — The Dojo Toolkit - Reference Guide&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Oct 2015 18:03:00 GMT</pubDate>
    <dc:creator>DanielStoelb</dc:creator>
    <dc:date>2015-10-29T18:03:00Z</dc:date>
    <item>
      <title>JavaScript Sample to widget</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/javascript-sample-to-widget/m-p/786887#M3686</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to build my first widget (while teaching myself JavaScript at the same time) and I'm using this JavaScript sample to perform a simple query &lt;A href="https://developers.arcgis.com/javascript/jssamples/query_nomap.html" title="https://developers.arcgis.com/javascript/jssamples/query_nomap.html"&gt;Query data without a map | ArcGIS API for JavaScript&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've got the query working alright, I put the code in the startup function. I can see the data is being returned by using alert(resultItems) but I can't wrap my head around how to get the results into a list in the side-panel. right now the panel only contains the mapIdNode example and I've hardcoded query.where so I'm just hoping to the results to display as a list or list box, combo box, anything&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course the sample is using one file and the widgets use multiple and this is where I don't know how to connect the two.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;one successful example will get me off to the races, I've self taught myself every other language ESRI has thrown at us (aml, avenue, python, xaml.....)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;GISr turned developer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Oct 2015 22:58:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/javascript-sample-to-widget/m-p/786887#M3686</guid>
      <dc:creator>DaveOrlando</dc:creator>
      <dc:date>2015-10-28T22:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript Sample to widget</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/javascript-sample-to-widget/m-p/786888#M3687</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dave,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; The path to understanding widget development in WAB is to understand dojo templated widgets. The widgets template has HTML or dojo dijits/widgets in it that have a data-dojo-attach-point this is what you use in the Widget.js to get access to the HTML object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;Widget.html&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;div&amp;gt;
&amp;nbsp; &amp;lt;div data-dojo-attach-point="selectedBasemapGalleryDiv" style="width:100%;height:100px;"&amp;gt;
&amp;nbsp; &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Widget.js&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;myFunction: function() {
&amp;nbsp; domConstruct.create('div', {
&amp;nbsp;&amp;nbsp;&amp;nbsp; 'class': 'bm-addbtn',
&amp;nbsp;&amp;nbsp;&amp;nbsp; 'id': 'someid',
&amp;nbsp;&amp;nbsp;&amp;nbsp; 'title': 'hello world'
&amp;nbsp; }, this.selectedBasemapGalleryDiv);
}&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So you can see in this example you get access to templated objects using "this" keyword dot the data-dojo-attach-point.&lt;/P&gt;&lt;P&gt;You also see the use of dojos domConstruct class to create basic html element in code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if you need more.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:58:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/javascript-sample-to-widget/m-p/786888#M3687</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-12T08:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript Sample to widget</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/javascript-sample-to-widget/m-p/786889#M3688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have the data in a deferred list and want to display it as items within the widget itself, I'd suggest creating a dom ID element in the widget.html file as Robert indicated above.&amp;nbsp; Then you could have the inidvidual items from the list within the widget.js file like the example I have below (from a tool I'm building), where I'm assigning a string value to a variable that then calls and sets the dom element:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;idstring = "Results: &amp;lt;br/&amp;gt;" +&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="line-height: 1.5;"&gt;"&amp;lt;br /&amp;gt;Number of Hospitals:&amp;nbsp; " + Hosp.length +&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; "&amp;lt;br /&amp;gt;Number of Medical Providers:&amp;nbsp; " + Med.length +&lt;/P&gt;&lt;P&gt;&amp;nbsp; "&amp;lt;br /&amp;gt;Number of Schools:&amp;nbsp; " + schools.length;&lt;/P&gt;&lt;P&gt;&amp;nbsp; dom.byId("results").innerHTML = idstring;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically, the widget.html file indicates what is shown on the screen and the widget.js is the underlying code for tasks that are performed by the widget.&amp;nbsp; Items within the html file are referred to as dom elements and can be referenced as shown in Robert's and my examples.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd suggest looking up this for more details:&amp;nbsp; &lt;A href="https://dojotoolkit.org/reference-guide/1.7/index.html" title="https://dojotoolkit.org/reference-guide/1.7/index.html"&gt;Dojo Toolkit Reference Guide — The Dojo Toolkit - Reference Guide&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2015 18:03:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/javascript-sample-to-widget/m-p/786889#M3688</guid>
      <dc:creator>DanielStoelb</dc:creator>
      <dc:date>2015-10-29T18:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript Sample to widget</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/javascript-sample-to-widget/m-p/786890#M3689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Robert, I got it working with the domConstruct as you suggested, but I had to hardcode some items to display.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var items = ['one', 'two', 'three', 'four'];
var listBox = domConstruct.create("select", null, this.queryList);
array.forEach(items, function (data) {
domConstruct.create("option", { innerHTML: data }, listBox);
});&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It took a while to realize that showResults can't see this.anything Very confusing Can you explain why and what to do with the results? I've seen a few of your responses with that lang.hitch..... is this an example where I should use this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:58:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/javascript-sample-to-widget/m-p/786890#M3689</guid>
      <dc:creator>DaveOrlando</dc:creator>
      <dc:date>2021-12-12T08:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript Sample to widget</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/javascript-sample-to-widget/m-p/786891#M3690</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dave,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Absolutely, using lang.hitch is the way to preserve the scope of the "this" object.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Oct 2015 18:44:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/javascript-sample-to-widget/m-p/786891#M3690</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2015-10-30T18:44:27Z</dc:date>
    </item>
  </channel>
</rss>

