When at first, I perform a buffer query the results of the query are added to a new custom feature layer. The attribute table adds the new feature layer at a new tab. Then, when I remove the feature layer (map.removeLayer([feat layer]), the attribute table refreshes by removing the new tab. When I attempt to call same query again, the attribute table does not add the feature layer any more. However, the I can see the features are selected on the map. Also, on the layer list, I can see the new feature layer is added and I can view the attribute table with the new tab by selecting "open attribute table".
I am using web appbuilder 1.3
Did anyone experience this behavior?
Thanks.
Solved! Go to Solution.
Robert,
I finally figured it out. As I was suspecting, the issue was with the attribute tables not refreshing after the first buffer. All the variables were initialized after removing a buffer, but still the attribute table would not show the new buffer layer. The solution was to force the attribute table to refresh by using the attribute table's function destroy instead of closing it. After that, the buffer layers appear on the attribute table after the first query.
closetable:function(){ var widgetCfg = this._getWidgetConfig('AttributeTable'); //console.log(widgetCfg); if (this.wManager) { var widgetCfg = this._getWidgetConfig('AttributeTable'); if(widgetCfg){ var attWidget = this.wManager.getWidgetByLabel(widgetCfg.label); this.attTableOpenedbySearch = !attWidget.showing; this.wManager.closeWidget(attWidget); //attWidget._closeTable(); attWidget.destroy(); } } },
Lefteris,
Sounds like you are maintaining a reference to the layer somewhere in your code and it is not being destroyed properly.
I don't understand. So, how is the new buffer layer shows up in the layer list and the attribute table when I select the option from the list, if I didn't destroy the old one?
Lefteris,
As always I can only speculate with out seeing the code you are using to add the layer and its vars and the code you use to set the layer object to null if it is a global var. But as you know I add and remove buffers and search layers all the time in my eSearch so it is something small that you are missing in your code.
Thank you Robert. My variables are indeed global and they are initialized as well. When the user remove the buffer layer, it calls a destroy function that initialize all the variables (featurelayers). I placed breakpoints at several locations to verify that the variables are null before the user calls another buffer. I looked in the esearch code, and it seems that I have a different approach. When features of a layer are found in the buffer, are added to a new feature layer with the name of layer name + " Buffer". When the buffer is removed, I search through the layers on the map that contain the "Buffer" in their name property and remove them. In esearch, it seems that all operational layers are defined from the results of the buffer and they are all removed prior the new query.
I have do some more head scratching to figure out what is wrong with my approach. Thank you again for your time.
Robert,
I finally figured it out. As I was suspecting, the issue was with the attribute tables not refreshing after the first buffer. All the variables were initialized after removing a buffer, but still the attribute table would not show the new buffer layer. The solution was to force the attribute table to refresh by using the attribute table's function destroy instead of closing it. After that, the buffer layers appear on the attribute table after the first query.
closetable:function(){ var widgetCfg = this._getWidgetConfig('AttributeTable'); //console.log(widgetCfg); if (this.wManager) { var widgetCfg = this._getWidgetConfig('AttributeTable'); if(widgetCfg){ var attWidget = this.wManager.getWidgetByLabel(widgetCfg.label); this.attTableOpenedbySearch = !attWidget.showing; this.wManager.closeWidget(attWidget); //attWidget._closeTable(); attWidget.destroy(); } } },
Lefteris,
Glad you got it working. I never ran into this issue doing it my way.