Hello,
In WAB Dev 2.0, how can I get names for layers shown in Attribute Table widget to be read from the Attribute Table config file:
\WABdev_2.0\server\apps\#\configs\AttributeTable\config_Attribute Table.json
Now, I apparently have no control over the names of layers in Attribute Table widget. For some layers, but not all, unwanted strings (usually consisting of one or more instances of the layer "id") are appended to layer names (shown in red on attached image). Even for layers without this erroneous name, I must change the layer names for the Attribute widget for various reasons.
The app in the image uses the custom LocalLayer widget to add layers, but the same issue occurs when AGOL Web Maps are called instead. The same issue occurs in WAB apps made in AGOL (without using WAB Dev edition).
Any help or ideas would be appreciated. My services are published using ArcGIS for Server 10.4.
Thanks in advance.
Solved! Go to Solution.
We were having the same issue and after a bit of investigation a co-work was able to resolve this by:
for(var i in this.config.layerInfos){
if(layerInfo.id == this.config.layerInfos.id){
return layerInfo.show && mLayerInfo &&
(layerInfo.name = this.config.layerInfos.name);
} else {
continue;
}
}
Hope this can help others.
Regards
Here is a shot of another WAB Dev 2.0 app, this one calling an AGOL Web Map. Note that problematic layer name in Attribute Table (shown in red) is on another layer than the one shown in map in previous post. All services are the same as shown in shot in previous post.
This looks like a new "feature" (bug?) in WD 2.0 Attribute Table widget. The Attribute Table config file is always synced with layer name from service, and thus edits of the attribute table config file are not read.
There were no such issues in WD 1.3 and older, and I could edit Attribute Table layer names in the config file.
// | utils.readConfigLayerInfosFromMap(this.map, true, true) |
utils.readConfigLayerInfosFromMap(this.map, false, true) | |
.then(lang.hitch(this, function(layerInfos) { | |
this._layerInfos = layerInfos; | |
this._processDelayedLayerInfos(); |
utils.readSupportTableInfoFromLayerInfos(this._layerInfos) | |
.then(lang.hitch(this, function(tableInfos) { | |
this._tableInfos = tableInfos; |
if (this.config && this.config.layerInfos && this.config.layerInfos.length > 0) { | |
// settting page should sync with webmap | |
var configInfosFromMap = utils.getConfigInfosFromLayerInfos(this._layerInfos); | |
utils.merge(configInfosFromMap, this.config.layerInfos, 'id', | |
lang.hitch(this, function(mci, cli) { | |
// mci.name = cli.name; | |
mci.show = cli.show; | |
mci.layer.url = cli.layer.url; | |
if (lang.getObject('layer.fields.length', false, mci) && | |
lang.getObject('layer.fields.length', false, cli)) { | |
utils.merge(mci.layer.fields, cli.layer.fields, 'name', function(d, s) { | |
lang.mixin(d, s); | |
}); | |
mci.layer.fields = utils.syncOrderWith( | |
mci.layer.fields, cli.layer.fields, 'name'); | |
} else { | |
mci.layer.fields = cli.layer.fields; | |
} | |
})); |
Above is a part of settings.js in
\WABdev_2.0\server\apps\#\widgets\AttributeTable\setting
Edit shown in red is for LocalLayer widget, "Changing that first 'true' to a 'false' will tell the menu to read all layers from the map as normal, instead of just ArcGIS Online layers."
Part shown in blue is responsible for layer name edits in Attribute Table widget config file not being shown in the widget editing GUI. If that line is uncommented, edits will be shown. However, such edits will not be saved when editing GUI is closed. I haven't figured out (yet?) how to make the edits be saved so that corrected layer names will show up in the Attribute Table.
Parts shown in orange are new to WAB 2.0 as compared to 1.3.
For the case of WAB 2.0 apps which call AGOL Web Maps, why isn't there at least the option of having the top-level layer names in the TOC to be the layer names shown in the Attribute Table? The top-level layer names of the services are configurable in the Web Map as shown below.
As it is now, the layer names in the Attribute table are always the names of the top-most group layer in the published service (if any), or some erroneous hybrid of layer name + layer id. I don't think that is a good idea, as the only way to change those names is to change the group layer name in the mxd prior to publishing. But in the case of the hybrid name, there is apparently no way at all to change it, leading to garbage for the name in the Attribute Table.
I hope that esri addresses this issue soon.
We were having the same issue and after a bit of investigation a co-work was able to resolve this by:
for(var i in this.config.layerInfos){
if(layerInfo.id == this.config.layerInfos.id){
return layerInfo.show && mLayerInfo &&
(layerInfo.name = this.config.layerInfos.name);
} else {
continue;
}
}
Hope this can help others.
Regards
Michael,
That works perfectly! Thank you very much.
Hopefully esri will make this edit unnecessary in the next WAB release!
Best regards,
Barnaby
This issue and the fix will force me to only use WAB Dev apps rather than AGOL WAB apps....
Looks like the edit is also needed for WAB Dev 2.1.
For WAB Dev 2.2, Adam Drackley found that Attribute Table layer names will be read from config file if the following edit is made to _ResourceManager.js file in the WABdev_2.2\server\apps\#\widgets\AttributeTable folder. For the change to be applied to the Attribute Table in future apps, make the change to the _ResourceManager.js file in the WABdev_2.2\client\stemapp\widgets\AttributeTable folder.
Edit: This change also works for WAB Dev 2.3.
Change this
return layerInfo.show && mLayerInfo &&
(layerInfo.name = mLayerInfo.name || mLayerInfo.title);
To this,
return layerInfo.show && mLayerInfo //&&
//(layerInfo.name = mLayerInfo.name || mLayerInfo.title);