Change Widget Settings from another Widget

148
7
Jump to solution
09-19-2019 12:21 PM
Highlighted
Occasional Contributor III

I'm working on creating a widget that will pass settings to the TimeSlider. So, I'm wanting to configure the time extent from one widget and update the time slider extent (settings in image). I'm not sure if I can access those settings or how to do so. Any help would be appreciated. Thx

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
MVP Esteemed Contributor

Brain,

  It sounds like you are trying to over think this. From your widget you get a reference to the time slider widget. The widget object has a config property that is an object that is hydrated when the widget actual json file is read. So once you have the reference to the widget.config you just change the values using widget.config.customTimeConfig.startTime.time = x.

View solution in original post

Reply
0 Kudos
7 Replies
Highlighted
MVP Esteemed Contributor

Brian,

   A widgets settings dialog just changes writes/edits value in that widgets config.json file. So you would just get a reference to the time sliders config and change it's values.

Reply
0 Kudos
Highlighted
Occasional Contributor III

These are the only setting in the config.json file...

{
"showLabels": false,
"autoPlay" : true,
"loopPlay": true,
"timeFormat": "auto"
}

Reply
0 Kudos
Highlighted
MVP Esteemed Contributor

Brain,

   The config.json file in the widgets folder is just the template for the real json file that is stored in the app configs/WIDGETNAME/XYZ.json file.

Highlighted
Occasional Contributor III

I was able to find the mentioned config file here (to reference for others).

"...\WebAppBuilderForArcGIS-213\server\apps\4\configs\TimeSlider\config_widgets_TimeSlider_Widget_20.json"

So, my question is how do I access/update the json for the the "customTimeConfig.startTime.time" and the "endTime.timeConfig.time" properties through another widget? I'm also using the "_getWidgetConfig" function to open the TimeSlider already, if that helps.

Thanks for all the help.

{
"showLabels": false,
"autoPlay": false,
"loopPlay": false,
"timeFormat": "auto",
"isHonorWebMap": false,
"customLayersConfig": [
{
"id": "[layer]",
"isTimeEnable": true
}
],
"customTimeConfig": {
"keepValueFlag": false,
"startTime": {
"timeConfig": {
"keepValueFlag": false,
"timeMode": "min",
"time": 1567191360000,
"calender": {
"operator": "",
"number": "",
"unit": ""
}
}
},
"endTime": {
"timeConfig": {
"keepValueFlag": false,
"timeMode": "max",
"time": 1568901360000,
"calender": {
"operator": "",
"number": "",
"unit": ""
}
}
},
"interval": {
"number": 2,
"units": "esriTimeUnitsDays"
},
"displayAllData": false
},
"customDateFormat": ""
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
Reply
0 Kudos
Highlighted
MVP Esteemed Contributor

Brain,

  It sounds like you are trying to over think this. From your widget you get a reference to the time slider widget. The widget object has a config property that is an object that is hydrated when the widget actual json file is read. So once you have the reference to the widget.config you just change the values using widget.config.customTimeConfig.startTime.time = x.

View solution in original post

Reply
0 Kudos
Highlighted
Occasional Contributor III

As usual, you came through again. Thanks for the quick responses and the help on this, it's greatly appreciated.

Reply
0 Kudos
Highlighted
Occasional Contributor III

Is this the reference you are talking about? This was located in the "ConfigureTimeSettings.js".

/*
timeConfigFromat = {
startTime:{
timeConfig: TimeCalendar.config
},
endTime:{
timeConfig: TimeCalendar.config
},
interval:{
number: null //number
units:""//esriTimeInfo.X
}
displayAllData: false//t / f
}
*/
// postCreate: function () {
// this.inherited(arguments);
// },

Reply
0 Kudos