Cannot read property 'set' of undefined this.FieldsCombo.set('store', FieldStore);

1308
7
Jump to solution
02-09-2019 02:58 AM
NadirHussain
Occasional Contributor

<div>
<label class="width70" for="FieldsCombo">Fields:</label>
<div data-dojo-attach-point="FieldsCombo" data-dojo-type="dijit/form/FilteringSelect" data-dojo-props="searchAttr:'name',intermediateChanges:true,placeHolder: 'Select Field'" class="dijit-form-FilteringSelect" style="width: 200px;height:30px;margin-Left: 51px;margin-top:5px;"></div>
</div>

this.SourceCombo.watch('displayedValue', function(property, oldValue, newValue) {
for(var k=0;k<layerInfoArray.length;k++)
{
if(layerInfoArray.title==newValue)
{
break;
}
}
var requestHandle = esriRequest({
"url": "https://localhost:6443/arcgis/rest/services/BaseMap/MapServer/"+k+"?f=pjson",
"content": {
"tags": "dog,us",
"tagmode": "all",
"format": "json"
},
"handeAs": "json",
"callbackParamName": "jsoncallback"
});
requestHandle.then(requestSucceeded, requestFailed);

function requestSucceeded(response, io){
var fields=(response["fields"]);
var FieldStore = new Memory({data: fields});
this.FieldsCombo.set('store', FieldStore);--------->this line produces errors
}
function requestFailed(error, io){
alert(dojoJson.toJson(error, true));
}
});

'cannot populate filteringselect 

Resultent data from rest end point

  1. 1: {name: "REGIONCODE", type: "esriFieldTypeString", alias: "كود المنطقة", length: 2, domain: {…}}
  2. 2: {name: "GOVCODE", type: "esriFieldTypeString", alias: "كود المحافظة", length: 5, domain: {…}}
  3. 3: {name: "CENTERCODE", type: "esriFieldTypeString", alias: "كود المركز", length: 9, domain: null}
  4. 4: {name: "NAMEAR", type: "esriFieldTypeString", alias: "الاسم بالعربية", length: 50, domain: null}
  5. 5: {name: "NAMEEN", type: "esriFieldTypeString", alias: "الاسم بالإنجليزية", length: 50, domain: null}
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Don't forget to mark this question as answered by clicking on the "Mark Correct" link on the reply that answered your question.

View solution in original post

0 Kudos
7 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Nadir,

   This is a similar issue as your last post. You have a scope issue "this" does not represent the widget in your requestSucceeded function because you have not hitched the scope.

requestHandle.then(lang.hitch(this, requestSucceeded), requestFailed);
0 Kudos
NadirHussain
Occasional Contributor

Dear Robert,

 I update the code as per your instructions but same error on same line.i use fieldsCombo with and without this key word.But same error on same place.

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Nadir,


  I will have to see your full widget code.

0 Kudos
NadirHussain
Occasional Contributor

var _map, _FeatureLayer, _graphicsUtils, _Draw, _Graphic,_StatisticDefinition, _SimpleMarkerSymbol, _Color,
_FindTask,_FindParameters,_SimpleLineSymbol,_geometryEngine, _Query, _QueryTask, _SimpleFillSymbol,
_SimpleRenderer,_Point,selectedRegionCode;
var URLs = {
"RegionServiceUrl":"https://localhost:6443/arcgis/rest/services/BaseMap/MapServer/2",
"GovServiceUrl":"https://localhost:6443/arcgis/rest/services/BaseMap/MapServer/1",
"CentersServiceUrl":"https://localhost:6443/arcgis/rest/services/BaseMap/MapServer/0",
"LocalitiesCentroidUrl": "https://localhost:6443/arcgis/rest/services/MOI/Tables/MapServer/"
}
var mapLayers = {RegionLayer:[],GovLayer:[],CentersLayer:[]},autoCompleteDataResult=[];
var selectedSymbol,slelctedPolygon,symbolRegion,symbolGov;
define(['dojo/_base/declare', 'jimu/BaseWidget','dojo/query',"dijit/form/Select", "esri/layers/FeatureLayer","esri/graphicsUtils",
"esri/toolbars/draw", "esri/graphic","esri/tasks/StatisticDefinition","esri/symbols/SimpleMarkerSymbol",
"esri/Color","esri/tasks/FindTask", "esri/tasks/FindParameters","esri/symbols/SimpleLineSymbol",
"esri/geometry/geometryEngine","esri/tasks/query",'jimu/LayerInfos/LayerInfos',"esri/tasks/QueryTask",
"esri/symbols/SimpleFillSymbol","esri/renderers/SimpleRenderer", "esri/geometry/Point",'dojo/store/Memory',
"dijit/_WidgetsInTemplateMixin",'dojo/_base/lang',"dojo/data/ObjectStore","esri/request", "dojo/_base/json",'dojo/on',"dojo/dom",
"dijit/form/FilteringSelect",
'jimu/loaderplugins/jquery-loader!./JS/jquery.min.js,./JS/jquery-ui.min.js,./JS/bootstrap.min.js,./JS/jsgrid.js,./JS/jsgrid.min.js'
],
function(declare,BaseWidget,query,Select,FeatureLayer,graphicsUtils,Draw,Graphic,StatisticDefinition,SimpleMarkerSymbol,
Color,FindTask,FindParameters, SimpleLineSymbol,geometryEngine,Query,LayerInfos ,QueryTask,SimpleFillSymbol,
SimpleRenderer,Point,Memory,_WidgetsInTemplateMixin,lang,ObjectStore,esriRequest,dojoJson,on,dom) {
//To create a widget, you need to derive from BaseWidget.
return declare([BaseWidget, _WidgetsInTemplateMixin], {
// Custom widget code goes here
name: 'SpatialSearchQuery',
baseClass: 'jimu-widget-SpatialSearchQuery',
postCreate: function() {
this.inherited(arguments);
console.log('postCreate');
},
startup: function() {
this.inherited(arguments);
var panel = this.getPanel();
panel.position.width = 260;
panel.position.height = 300;
panel.setPosition(panel.position);
panel.panelManager.normalizePanel(panel);
_map = this.map;
_FeatureLayer = FeatureLayer;
_graphicsUtils = graphicsUtils;
_Draw = Draw;
_Graphic = Graphic;
_StatisticDefinition = StatisticDefinition;
_SimpleMarkerSymbol = SimpleMarkerSymbol;
_Color = Color;
_FindTask = FindTask;
_FindParameters = FindParameters;
_SimpleLineSymbol = SimpleLineSymbol;
_geometryEngine = geometryEngine;
_Query = Query;
_QueryTask = QueryTask;
_SimpleFillSymbol = SimpleFillSymbol;
_SimpleRenderer = SimpleRenderer;
_Point = Point;


var layerInfoArray=[];
var lyrArray=[];
if (this.map.itemId) {
LayerInfos.getInstance(this.map, this.map.itemInfo)
.then(lang.hitch(this, function(operLayerInfos) {
this.operLayerInfos = operLayerInfos;
}));
}
this.operLayerInfos.traversal(lang.hitch(this, function(layerInfo) {
layerInfoArray.push(layerInfo);
}));
for(var k=1;k<layerInfoArray.length;k++)
{
lyrArray.push({"ID":layerInfoArray.id,"Title":layerInfoArray.title});
}
var myStore = new Memory({data: lyrArray});
this.SourceCombo.set('store', myStore);
this.TargetCombo.set('store', myStore);

//this.SourceCombo.on('change', lang.hitch(this, function(){
// console.log("Hello");
// alert("ffff");
//_getAllFields("Hello");
// }));
this.SourceCombo.watch('displayedValue', function(property, oldValue, newValue) {
for(var k=0;k<layerInfoArray.length;k++)
{
if(layerInfoArray.title==newValue)
break;
}
var requestHandle = esriRequest({
"url": "https://localhost:6443/arcgis/rest/services/BaseMap/MapServer/"+k+"?f=pjson",
"content": {
"tags": "dog,us",
"tagmode": "all",
"format": "json"
},
"handeAs": "json",
"callbackParamName": "jsoncallback"
});

requestHandle.then(lang.hitch(this, requestSucceeded), requestFailed);
function requestSucceeded(response, io){
var fields=(response["fields"]);
var FieldStore = new Memory({data: fields});
//var os = new ObjectStore({ objectStore: FieldStore });
this.FieldsCombo.set('store', FieldStore);
}
function requestFailed(error, io){
alert(dojoJson.toJson(error, true));
}
});
},
_getAllFields:function (strLayerName,lyrInfoArray){
alert("In side"+strLayerName);
for(var k=1;k<layerInfoArray.length;k++)
{
if(layerInfoArray.title==strLayerName)
{
break;
}
}
},

onOpen: function(){
console.log('onOpen');
},

onClose: function(){
console.log('onClose');
},

// onMinimize: function(){
// console.log('onMinimize');
// },

// onMaximize: function(){
// console.log('onMaximize');
// },

// onSignIn: function(credential){
// /* jshint unused:false*/
// console.log('onSignIn');
// },

// onSignOut: function(){
// console.log('onSignOut');
// }

// onPositionChange: function(){
// console.log('onPositionChange');
// },

// resize: function(){
// console.log('resize');
// }

//methods to communication between widgets:

});
});


0 Kudos
NadirHussain
Occasional Contributor

<div>
<div >
<label class="width70" for="SourceCombo" style="margin-top:-20px">Source Layer:</label>
<div data-dojo-attach-point="SourceCombo" data-dojo-type="dijit/form/FilteringSelect" data-dojo-props="searchAttr:'Title',intermediateChanges:true,placeHolder: 'Select Source Layer'" class="dijit-form-FilteringSelect" style="width: 360px;height:30px;margin-Left: 10px;margin-top:-10px;"></div>
</div>
<div>
<label class="width70" for="TargetCombo">Target Layer:</label>
<div data-dojo-attach-point="TargetCombo" data-dojo-type="dijit/form/FilteringSelect" data-dojo-props="searchAttr:'Title',intermediateChanges:true,placeHolder: 'Select target Layer'" class="dijit-form-FilteringSelect" style="width: 360px;height:30px;margin-Left: 14px;margin-top:1px;"></div>
</div>
<div>
<label class="width70" for="FieldsCombo">Fields:</label>
<div data-dojo-attach-point="FieldsCombo" data-dojo-type="dijit/form/FilteringSelect" data-dojo-props="searchAttr:'name',intermediateChanges:true,placeHolder: 'Select Field'" class="dijit-form-FilteringSelect" style="width: 200px;height:30px;margin-Left: 51px;margin-top:5px;"></div>
</div>
</div>

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Nadir,

  OK, I see your issue now. Your requestSucceeded function is inside the this.SourceCombo.watch('displayedValue', function. So you need:

        this.SourceCombo.watch('displayedValue', lang.hitch(this, function(property, oldValue, newValue) {
for (var k = 0; k < layerInfoArray.length; k++) {
if (layerInfoArray[k].title == newValue)
break;
}
var requestHandle = esriRequest({
"url": "https://localhost:6443/arcgis/rest/services/BaseMap/MapServer/" + k + "?f=pjson",
"content": {
"tags": "dog,us",
"tagmode": "all",
"format": "json"
},
"handeAs": "json",
"callbackParamName": "jsoncallback"
});

requestHandle.then(lang.hitch(this, requestSucceeded), requestFailed);

function requestSucceeded(response, io) {
var fields = (response["fields"]);
var FieldStore = new Memory({
data: fields
});
//var os = new ObjectStore({ objectStore: FieldStore });
this.FieldsCombo.set('store', FieldStore);
}

function requestFailed(error, io) {
alert(dojoJson.toJson(error, true));
}
}));
0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Don't forget to mark this question as answered by clicking on the "Mark Correct" link on the reply that answered your question.

View solution in original post

0 Kudos