Select to view content in your preferred language

Get the featureSet from XxxFeatureAction class to print (or use) it in Widget.js

2189
10
Jump to solution
10-14-2016 07:46 PM
RolandoFlorez
Occasional Contributor

rscheitlin

I need to ask you one more thing... The class @XxxFeatureAction derive from BaseFeatureAction.
Can you explain me about isFeatureSupported and onExecute function?

How can I send data ( a featureSet.fields.values() ) from this class to Widget.js.

 

This line make that:

myWidget.showVertexCount(featureSet.fields.values());

 

in Widget.js 

showVertexCount: function(count){
this.vertexCount.innerHTML = 'The vertex count is: ' + count;
}

this method receives that information.

I've been trying to print that but it shows me null. I don't know why. 

Do you understand me?

Thanks a lot

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Rolando,

The isFeatureSupported method is where you write your code to determine if this feature action should be available. So if you want your feature action to only be available for a specific layer then you would use the optional Layer parameter of that method to determine if you are working with the correct layer. The isFeatureSupported has FeatureSet property and an optional Layer property.

As far as sending data back to a widget I would use a global var in your widget to pass the info. You mention that you are trying that already, but which out seeing your code I could not tell you what you are doing wrong (are you sure you have a true widget object as your myWidget var?).

View solution in original post

0 Kudos
10 Replies
RobertScheitlin__GISP
MVP Emeritus

Rolando,

The isFeatureSupported method is where you write your code to determine if this feature action should be available. So if you want your feature action to only be available for a specific layer then you would use the optional Layer parameter of that method to determine if you are working with the correct layer. The isFeatureSupported has FeatureSet property and an optional Layer property.

As far as sending data back to a widget I would use a global var in your widget to pass the info. You mention that you are trying that already, but which out seeing your code I could not tell you what you are doing wrong (are you sure you have a true widget object as your myWidget var?).

0 Kudos
RolandoFlorez
Occasional Contributor

Look Robert, I modified this: 

I suppose that this.widgetId make reference to widget that I'm working (MyWidget). All this are in MyWidget folder

onExecute : function (featureSet) {
WidgetManager.getInstance().triggerWidgetOpen(this.widgetId)
.then(function (myWidget) {

   var arrVal= featureSet.fields.values();
   myWidget.showVertexCount(arrVal);
});

I think that this function have to send arrVal variable to the showVertextCount function in Widget.js. Or that's wrong? 

I did it the same like Demo widget, that interacts with Select widget. (maybe I'm wrong)

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Rolando,

  Is your widget opening?

0 Kudos
RolandoFlorez
Occasional Contributor

yes Robert, when I click in query button, must print arrVal

but, this is the result:

Now, arrVal is a global variable and _theLastTry runs when I click query button (Widget.js)

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Rolando,

   Have you tried putting a console.log(arrVal); in your showVertexCount function?

0 Kudos
RolandoFlorez
Occasional Contributor

Robert, I just did it, but it doesn't work.

Look, I want to do this (but with arrVal)

if you have any idea, It would be great.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Rolando,

   So did the console print null for that console.log line?

0 Kudos
RolandoFlorez
Occasional Contributor

Yes Robert, it prints null 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

in your onExecute function have you checked the arrVal with s console statement before it is passed to the widget?

0 Kudos