AnsweredAssumed Answered

Open Table in HTML from Button

Question asked by brandon.price on Dec 18, 2017
Latest reply on Dec 19, 2017 by brandon.price

Hello,

 

I created a table that I have in my html that I am trying to access from a button (PMSelect) that I also have in my html. The table (script id="utilitySelectorTmpl") and javascript (utilitySelectorModule.js to query the restpage) to populate the table are done. I have not been able to open the table using onclick. This is what I have:

 

var utilitySelectorToolBtn = dom.byId("PMSelect");
   on(utilitySelectorToolBtn, "click", function (event) {
   if (app.isutilitySelectorModuleOpen === true) {
      app.utilitySelectorModule.hide();
      app.isUtilitySelectorOpen = false;
   } else { // not open
      app.utilitySelectorModule.show();
      app.isutilitySelectorModuleOpen = true;
   }
});

 

I haven't yet specified the location of table when open. Maybe this could be the reason but I am not sure. This is a portion of my script:

 

app.utilitySelectorModule = {

   countyField: 'Cnty',
   routeField: 'Route',
   postmileField: 'DYNSEGPM',

 

   isVisible: false,

   template: {},
   panel: {},
   countyDllEl: {},
   routeDllEl: {},
   beginPostMarkerDdlEl: {},
   endPostMarkerDdlEl: {},

 

init: function () {
}, // init

 

show: function () {
   require(["dojo/on",
      "dojo/_base/declare", "dojo/dom-construct",
      "esri/tasks/QueryTask", "esri/tasks/query"
   ], function (on, declare, domConstruct, QueryTask, Query) {
         let ctx = app.utilitySelectorModule;
         ctx.isVisible = true;
         if (!ctx.panel.click) {

         ctx.panel = domConstruct.toDom("<div class='utilitySelectorPnl'></div>");
         domConstruct.place(ctx.panel, 'mainHtmlBody')

         template = $("#utilitySelectorTmpl");
         ctx.panel.innerHTML = template.html()

 

Attached are the two js files. Custom scripts has the button and utilityselectormodule has the query commands for the table. Any help is greatly appreciated.

 

Brandon

 

ArcGIS API for JavaScript

Web GIS

Web AppBuilder Custom Widgets

Outcomes