Why is my grid undefined?

1338
6
Jump to solution
05-12-2017 10:53 AM
KenBuja
MVP Esteemed Contributor

In my widget, I'm creating a grid that will hold summary information on a feature layer. The grid is added to the widget, but the variable I have it assigned to is undefined. Where is my logic going wrong on this?

Here is where I'm initialize the variable names

    return declare([BaseWidget, _WidgetsInTemplateMixin], {

      baseClass: 'jimu-widget-spatialprioritization',
      name: 'Spatial Prioritization',
      _togSignin: null,
      _gridTotals: null,
      _layerSPGrid: null,
      _arrayTotals: null,
      _SPGridUrl: null,
      _rendererPriority: null,

and later on, here's where I instantiate the grid once the layer is loaded

      this._layerSPGrid.on("load", lang.hitch(this, function () {
        this._createTotalGrid();
      }));
 
      _createTotalGrid: function () {
        this._gridTotals = new Grid({
          id: 'gridPriority',
          columns: {
            priority: { label: "Priority", sortable: false },
            existing: { label: "Current", sortable: false },
            selected: { label: "Selected", sortable: false }
          },
          className: "gridpriority"
        }, this.totalGrid).startup();
        this._updateGridFeatures([]);
      },

The empty grid is added to the panel, but its reference is undefined. Why is that?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Ken,

   Just out of curiosity what happen if you move the startup to another line instead of chaining it like you have.

View solution in original post

6 Replies
RobertScheitlin__GISP
MVP Emeritus

Ken,

  Nothing is jumping out. You have a div with data-dojo-attach-point="totalGrid" in your widget.html right?

0 Kudos
KenBuja
MVP Esteemed Contributor

Yes I do. The grid is attached to the panel, as shown in the screenshot.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Ken,

   Is it just a timing issue? If you wait longer is the var not null?

0 Kudos
KenBuja
MVP Esteemed Contributor

Unfortunately not. When I click the Signout button, I have a line to destroy the dijit. But it's still undefined there (not just null).

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Ken,

   Just out of curiosity what happen if you move the startup to another line instead of chaining it like you have.

KenBuja
MVP Esteemed Contributor

That appears to have done it. Which leads to another question, but I'll start that in a separate thread next week.

Thanks for your help, Robert!

0 Kudos