Thanks again Robert. Now I am trying to get the response from the web api that I use for querying a remote database. In a C# windows form, I have no problems doing this, but in this widget I am not totally sure where to put my code. I'm currently just hardcoding some sample data to see if I can get some results, but after the myWidget.showContractNumber, the code stops working. What should be happening is just 3 consecutive message boxes with the name showing.
Any advice on where I am going wrong??
define([
'dojo/_base/declare',
'jimu/BaseFeatureAction',
'jimu/WidgetManager'
],
function (declare, BaseFeatureAction, WidgetManager)
{
var clazz = declare(BaseFeatureAction,
{
iconFormat: 'png',
isFeatureSupported: function (featureSet)
{
return featureSet.features.length > 0 && featureSet.features[0].geometry.type !== 'point';
},
onExecute: function (featureSet)
{
WidgetManager.getInstance().triggerWidgetOpen(this.widgetId)
.then(function (myWidget)
{
var vertexCount = 0;
var contractNumber = "TEST";
featureSet.features.forEach(function (f)
{
f.geometry.rings.forEach(function (r)
{
vertexCount += r.length;
});
contractNumber = f.attributes.CONTRACTNO;
});
myWidget.showVertexCount(vertexCount);
myWidget.showContractNumber(contractNumber);
$(document).ready(function () {
var jsonData = [{
"itemsPerPage": 25,
"list": [{
"id": "1018",
"name": "abc"
}, {
"id": "1019",
"name": "acd"
}, {
"id": "1025",
"name": "kjk"
}]
}];
$.each(jsonData, function (i, item) {
$(item.list).each(function (key, value) {
alert(value.name);
});
});
});
});
},
});
return clazz;
});