Combining multiple widgets into 1 - getting Error when combining widgets

557
2
Jump to solution
02-25-2021 12:12 PM
by Anonymous User
Not applicable

I have been creating a custom widget that consists of a few 'applications.' I created 3 different widgets and got them all to work and then started to combine them - 2 of them great, then adding the 3rd widget I get the following error: TypeError: UniqueValueRenderer is not a constructor
at Object.postCreate (:3344/webappbuilder/stemapp/widgets/Location/Widget.js?wab_dv=2.18:95).........

I would then go line by line and try to rewrite in a different format getting it to work, but it is almost like anything related to the UniqueValueRenderer import was not accepted when defined in the beginning.  'esri/renderers/UniqueValueRenderer' is in the Define[] at top and UniqueValueRenderer in Functions[];    Below is functions where used:

This particular widgets works fine, until I try to combine with another widget then I get the TypeError. Any ideas? Or maybe something I can use other than UniqueValueRenderer

postCreate: function() {
this.inherited(arguments);
console.log('postCreate');
//this._initTabContainer();

m_lyrAllFacilities = new FeatureLayer(
this.config.facilitiesURL, { "mode": FeatureLayer.MODE_SNAPSHOT, "outFields": ["*"] });
m_zoomToFacilities = m_lyrAllFacilities.on('update-end', this.zoomToFacilities);

m_lyrResultRoutes = new GraphicsLayer();
m_lyrEvents = new GraphicsLayer();
m_lyrBarriers = new GraphicsLayer();

var slsDefault = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([32, 32, 32]), 2);
var resultRenderer = new UniqueValueRenderer(slsDefault, this.config.symbology.routeRenderer.field1);
for (var i = 0; i < this.config.symbology.routeRenderer.uniqueValueInfos.length; i++) {
var info = this.config.symbology.routeRenderer.uniqueValueInfos[i];
var sls = new SimpleLineSymbol(info.style, info.sym.color, info.sym.width);
resultRenderer.addValue(info.value, sls);
}
m_lyrResultRoutes.setRenderer(resultRenderer);

m_drawToolbar = new Draw(this.map);
var sms = new SimpleMarkerSymbol(this.config.symbology.eventSymbol);
m_drawToolbar.setMarkerSymbol(sms);
var sls = new SimpleLineSymbol(this.config.symbology.barrierSymbol);
m_drawToolbar.setLineSymbol(sls);
m_drawToolbar.on("draw-complete", lang.hitch(this, this.onDrawEvent));

m_closestFacilityTask = new ClosestFacilityTask(this.config.closestFacilitySvc.url);
},

startup: function() {
this.inherited(arguments);
console.log('startup');

var rankNumbers = dom.byId("trRankNumbers");
var rankColors = dom.byId("trRankColors");
for (var i = 0; i < this.config.symbology.routeRenderer.uniqueValueInfos.length; i++) {
var info = this.config.symbology.routeRenderer.uniqueValueInfos[i];
var className = this.getRankSymbolDomClassName(info.value);
var aryColor = info.sym.color;

var tdRankNumber = '<td class="' + className + '" '
+ 'style="text-align:center;">' + info.value + '</td>';
domConstruct.place(tdRankNumber, rankNumbers);

var tdRankColor = '<td class="' + className + '" ' +
'style="background-color:rgba(' +
aryColor[0] + ',' + aryColor[1] + ',' + aryColor[2] + ',' + aryColor[3] + ')' +
';width:15px;height:15px;">&nbsp;</td>'
domConstruct.place(tdRankColor, rankColors);
}

 onChangeFacilitiesCount: function (event) {
console.log("Change Facilities Count: " + event.currentTarget.value);
var count = event.currentTarget.value;
for (var i = 0; i < this.config.symbology.routeRenderer.uniqueValueInfos.length; i++) {
var className = this.getRankSymbolDomClassName(i + 1);
if (i + 1 <= count)
query("." + className).style("visibility", "visible");
else
query("." + className).style("visibility", "hidden");
}
},

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

Have you checked whether the order of the require modules and the function arguments are correct?

View solution in original post

0 Kudos
2 Replies
KenBuja
MVP Esteemed Contributor

Have you checked whether the order of the require modules and the function arguments are correct?

0 Kudos
by Anonymous User
Not applicable

You were right! Somehow I had misplaced 2 of them! Thank you so much. I still have a TypeError: stating it can't read a property path or undefined, but I think this one I can hopefully work through.

Thank you, It never occurred to me because I did a simple copy and paste, but I must have missed when I went through deleting duplicates. 

0 Kudos