Open Table in HTML from Button

1372
4
12-18-2017 01:24 PM
BrandonPrice
Occasional Contributor

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

Tags (2)
0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus

Brandon,

   I have not seen this type of coding workflow before so it is hard to say whats going wrong. Are you even getting anything added to the mainHtmlBody?

0 Kudos
BrandonPrice
Occasional Contributor

Only the button appears in the map which was added to the map div in the html. The table does not show when you click the button yet. I believe it might be something not too challenging that needs some revision for it to work.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Brandon,

  Unfortunately I am having trouble following your code logic.

0 Kudos
BrandonPrice
Occasional Contributor

No problem. Thanks for the response. I will post any solutions.

0 Kudos