AnsweredAssumed Answered

Registry Error in Custom Widget

Question asked by abhinavsharma1 on Jan 24, 2018
Latest reply on Jan 26, 2018 by kenbuja

//Updated define //

//updated last line from fields to fieldNames// 

Hi everyone, I am attempting to expand my widget by adding in a renderer that is is available to the end user. I have been working my way through the following ESRI Sample. The sample is for a mapservice and not a feature layer but I do not see why the same idea can not be applied. The issue is in bold. It stops at both of those instances. I have used console.log to see if there is any difference in the object that is being passed. ( Looked at the object in the sample and compared to my own) and the only difference i can find is when i print out fieldname after the push: using (console.log("fieldnames", fieldNames)


the sample looks like this:


  1. {identifier: "value", label: "name", items: Array(2)}
    1. identifier:"value"
    2. items:Array(10)
      1. 0:
        1. name:["FIPS"]
        2. value:["FIPS"]
        3. _0:0
        4. _RI:true
        5. _S:{_arrayOfAllItems: Array(10), _arrayOfTopLevelItems: Array(10), _loadFinished: true, _jsonFileUrl: undefined, _ccUrl: undefined, …}
        6. __proto__:Object 

whereas from my widget it looks like this:


  1. {identifier: "value", label: "name", items: Array(1)}
    1. identifier:"value"
    2. items:Array(19)
      1. 0:
        1. name:"OBJECTID"
        2. value:"OBJECTID"



TypeError: Cannot read property 'on' of undefined

function(declare, BaseWidget, Draw, Edit, Graphic, esriRequest, esriConfig,
ClassBreaksDefinition, UniqueValueDefinition, AlgorithmicColorRamp,
GenerateRendererParameters, GenerateRendererTask, LayerDrawingOptions,
SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol,
arrayUtils, event, lang, parser, registry, ItemFileReadStore, DataGrid, FilteringSelect) {
//To create a widget, you need to derive from BaseWidget.
return declare([BaseWidget], {
// DemoWidget code goes here
//please note that this property is be set by the framework when widget is loaded.
//templateString: template,
baseClass: 'jimu-widget-ROP',
postCreate: function() {
startup: function() {
// refer to "Using the Proxy Page" for more information: = "/proxy/";
map.on("layers-add-result", initEditing);

var landusePolygonLayer = new FeatureLayer("MyLayer", {
id: "canada_Risk",//confirm works
mode: FeatureLayer.MODE_ONDEMAND,
outFields: ["*"]
console.log("LayerInfo", landusePolygonLayer)
var canadaFields = esriRequest({
f: "json"
callbackParamName : "callback"
console.log("fields", canadaFields)
var fieldNames, fieldStore;
fieldNames = { identifier : "value", label: "name", items: []};
console.log("fields", fieldNames)
fieldNames.items.push({"name":, "value":});
console.log("fieldnames", fieldNames)
fieldStore = new ItemFileReadStore({ data:fieldNames});
console.log("store", fieldStore)
registry.byId("fieldNames").set("store", fieldStore);
}, function(err){
console.log("failed to get field names: ", err);
//update when field name changes
registry.byId("fieldNames").on("change", getData);