How to pass the data from one widget to another widget

973
3
02-07-2019 05:23 AM
tarunvisvanadula1
New Contributor II

hi i have array of data in a widget ,i have published it using below method,

this.publishData({
'target':"Labelwidget"
'data': currentWidget.publishObj
});


i was unable to access the data from other widget

this.fetchDataByName('visiblelayerwidget');

i have taken widget communication sample has reference.

so,please help me in this

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

Tarun,

   Do you have an onRecieveData function in your Labelwidget?

Here I would have my visiblelayerwidget:

startup: function(){
  this.inherited(arguments);
  // this is so you can catch any communication that occured before your widget started up
  this.fetchData();
  ...
},

onReceiveData: function(name, source, params) {
  if (params && params.target === "Labelwidget") {
    //do something with params.data
  }
},‍‍‍‍‍‍‍‍‍‍
0 Kudos
tarunvisvanadula1
New Contributor II

hi robert,

Thanks for the support,i have doubt is it possible to use below method more than once in single widget? 

this.publishData({
'target':"Labelwidget"
'data': currentWidget.publishObj
}); 

Example:

this.publishData({
'target':"Labelwidget"
'data': currentWidget.publishObj
}); 

this.publishData({
'target':"searchwidget"
'data': currentWidget.publishObjects
}); 

please check the above example ,if it is possible using publish data more than once in single widget please let me know

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Tarun,

   Not sure why you would want to since your data property can be an object with multiple properties (i.e. and object that has multiple objects). As far as I know yes you can call publishData as much as you want though.

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

0 Kudos