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.
Florian,
You can use "jimu/WidgetManager" in your require for one of your widgets and then use:
var theWhereClause = WidgetManager.getInstance().getWidgetsByName('YourOtherWidgetsName').YOURPUBLICVAR;
Your other widget would need to have a public var like this:
return declare([_WidgetBase, _TemplatedMixin], { templateString: template, _currentSelectedBookmarkRowNode: null, _currentSelectedBookmarkLoadingDiv: null, _lastExtent: null, YOURPUBLICVAR: 'something',
Florian,
You can use "jimu/WidgetManager" in your require for one of your widgets and then use:
var theWhereClause = WidgetManager.getInstance().getWidgetsByName('YourOtherWidgetsName').YOURPUBLICVAR;
Your other widget would need to have a public var like this:
return declare([_WidgetBase, _TemplatedMixin], { templateString: template, _currentSelectedBookmarkRowNode: null, _currentSelectedBookmarkLoadingDiv: null, _lastExtent: null, YOURPUBLICVAR: 'something',
So If I understand, I have two widgets :
In the first one where the whereClause is defined by selectors (because the whereClause is Dynamic...doesn't generate problems ?) I have to define the Widget Manager and the public var.
And in the second one where the whereClause will be re-used for another query, I just have to define the var whereClause in the :
return declare([ BaseWidget, _WidgetsInTemplateMixin],{
baseClass: 'jimu-widget-test',
name: 'Test_Dashboard',
var whereClause = blablabla...,
Or I didn't understood ?
(sorry by advance but I'm a beginner...)
Florian,
You define the dynamic whereClause in widgetA and in widgetB you add the widgetManger and retrieve the dynamic whereClause from widgetA. Now what triggers widgetB to retrieve the dynamic whereClause in widgetA is another question.
What is your desired workflow?
The better workflow should be the dynamic refresh of the whereclause ! How do you think is it possible to do this ?
Florian,
OK then this would be the better route then:
WidgetA has the dynamic whereClause and when it changes you fire off a function that calls a function that exists in widgetB. You get access to the function in widgetB using WidgetManager.getInstance().getWidgetsByName('widgetB').executeQuery(newWhereClauseVar);
So widgetB would have to have a "executeQuery" function that take a parameter for the whereClause string. Let me know if this is enough to go on.
hmmm juste a question : Am I forced to use the var theWhereClause = WidgetManager.getInstance().getWidgetsByName('YourOtherWidgetsName').YOURPUBLICVAR; Becauce by my side, this syntax doesn't work (theWhereClause is undefined) but the YOURPUBLICVAR can be used simply and sent me back the good value ... I don't really understand this behavior...
For the workflow it seems to be great, I'll try to make run something like that !
Florian,
No you can use whatever var name you want or not actually set a var. You can just do something like this (if you want):
query.where = WidgetManager.getInstance().getWidgetsByName('YourOtherWidgetsName').YOURPUBLICVAR;
ahah no, my problem is not the name of the variable but the WidgetManager.getInstance().getWidgetsByName('nameofwidget').publicvar; ... I dont understand why my Widget B can understand the Widget A's publicvar but not the Widget B's created var (with the .getinstance.getwidgetbyname...syntax) !
That's why I ask if it is usefull and/or forced to use the "...WidgetManager.getInstance().getWidgetsByName('widgetname')..." syntax ?
Florian,
OK, you have me confused...
WidgetB can get to WidgetAs var because it is global (based on this code):
define(['dojo/_base/declare', 'jimu/BaseWidget'], function(declare, BaseWidget) { return declare([BaseWidget], { baseClass: 'toggle-basemap-widget', name: 'ToggleBasemap', myWhereClause: '', // DO NOT use "var" myWhereClause as that make it local.
So yes you are forced to use the ...WidgetManager.getInstance().getWidgetsByName('widgetname')... syntax. This is the way that WidgetA knows what WidgetB is.
So using the above code sample the code would look like this:
query.where = WidgetManager.getInstance().getWidgetsByName('ToggleBasemap').myWhereClause;