issue with attribute table?

2464
6
Jump to solution
01-12-2016 02:47 PM
LefterisKoumis
Occasional Contributor III

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.

0 Kudos
1 Solution

Accepted Solutions
LefterisKoumis
Occasional Contributor III

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();
  }
  }
  },

View solution in original post

0 Kudos
6 Replies
RobertScheitlin__GISP
MVP Emeritus

Lefteris,

   Sounds like you are maintaining a reference to the layer somewhere in your code and it is not being destroyed properly.

0 Kudos
LefterisKoumis
Occasional Contributor III

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?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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.

0 Kudos
LefterisKoumis
Occasional Contributor III

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.

0 Kudos
LefterisKoumis
Occasional Contributor III

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();
  }
  }
  },
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Lefteris,

   Glad you got it working. I never ran into this issue doing it my way.

0 Kudos