Hi everyone,
I'm sorry by advance for my question, I'm a beguiner with the Web App Builder for Developpers...
I have two different widget, one for visualisation and another for basics statistics. For each one, I use a query where the where clause is in a variable and I would like them to use the same where clause but I don't how to do for make them sharing this variable.
Thank you for your help !
Solved! Go to Solution.
Okay juste going from the basics :
In my Widget A (with whereClause Selector) I have :
define([ 'dojo/_base/declare', 'dijit/_WidgetsInTemplateMixin', 'jimu/BaseWidget', ... function( declare, _WidgetsInTemplateMixin, BaseWidget, ... return declare([ BaseWidget, _WidgetsInTemplateMixin],{ baseClass: 'blabla', name: 'blablabla', theWhereClause: '', ... theSelectorFunction: function(){ blablablablablabla ... theWhereClause = "DateSelected = '16/02/2015'"; ...
And in the Widget B (where I want to use the whereClause value for another query) I have :
define([ 'dojo/_base/declare', 'dijit/_WidgetsInTemplateMixin', 'jimu/BaseWidget', 'jimu/WidgetManager', ... function( declare, _WidgetsInTemplateMixin, BaseWidget, WidgetManager, ... return declare([ BaseWidget, _WidgetsInTemplateMixin],{ baseClass: 'blabla', name: 'ahahah', ... onOpen: function(){ var myWhereClause = WidgetManager.getInstance().getWidgetsByName('blablabla').theWhereClause; console.log(myWhereClause); console.log(theWhereClause); ...
And with that, myWhereClause return "undefined" and theWhereClause return "DateSelected = '16/02/2015'"
(the value selected with the widget A !) So now I don't understand what append...
sh*t my answer had a bug too ! Can you read easily what I writed or do you want me to re-edit this ?
(I don't know why but the end of my message is write in white)
Florian,
OK, I see the result of console.log(theWhereClause);
I have to say that I have never seen the ability to get a widgets var by doing it that way from another widget...
Florian,
Not sure why you are not getting the value. Try adding this line to widgetB:
console.info(WidgetManager.getInstance().getWidgetsByName('blablabla'));
and see if you are actually getting the widget object.
ahahah I don't know if it is a good thing or not...
So that's why I ask this question, because this way seems to be the simplest one but I don't know if it can generate some problems...
And the console.info(WidgetManager.getInstance().getWidgetsByName('blablabla')); gimme back a [] and nothing else...I don't know if it's good or not too ...
Florian,
I am so sorry. I forgot that widget manager returns an array when searching for a widget by name. So the code should be:
query.where = WidgetManager.getInstance().getWidgetsByName('ToggleBasemap')[0].myWhereClause;
Yes I think that getting the myWhereClause the other way will be an issue.
No problem, don't worry !
The WidgetManager.getInstance().getWidgetsByName('ToggleBasemap')[0].myWhereClause; method don't gimme back anything ... It's juste blank in the console...
Florian,
Lets have you try to get a variable from a esri widget that is normally loaded with WAB to test then.
console.info(WidgetManager.getInstance().getWidgetsByName('Geocoder')[0].hardcodeRegExp);
The result should be: "/geocode(.){0,3}\.arcgis.com\/arcgis\/rest\/services\/World\/GeocodeServer/g"
Oh sorry I made a mistake into the code of my first widget, so now, it's ok for the .get.get(blablablah) syntaxe !
I call myWhereClause variable with .get.get() in the onOpen function so the whereclause is refreshed more or less each time I open my Widget B...and after it's going on I think... Not working well at this time, but it will be ok !
thank you for your help !