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?
Solved! Go to Solution.
Ken,
Just out of curiosity what happen if you move the startup to another line instead of chaining it like you have.
Ken,
Nothing is jumping out. You have a div with data-dojo-attach-point="totalGrid" in your widget.html right?
Yes I do. The grid is attached to the panel, as shown in the screenshot.
Ken,
Is it just a timing issue? If you wait longer is the var not null?
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).
Ken,
Just out of curiosity what happen if you move the startup to another line instead of chaining it like you have.
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!