Remove all the tabs contained in the AttributeTable widget

542
3
11-30-2016 09:12 AM
GilbertoMatos
Occasional Contributor II

Hello!

I need to remove all the tabs contained in the AttributeTable widget, before giving a publish of a new graphic layer added to the map. Is there any way to do this? I am using JavaScript API.

Note: I want to remove all AttributeTable tabs from within the geoprocessing widget.

Thank you!
Gilberto.

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Gilberto,

   I don't  use the GP widget but here is some code fro closing all the tabs on the AT widget:

define([
...
  'jimu/WidgetManager',
...
function (
...
  WidgetManager,
...
) {
this.wManager = WidgetManager.getInstance();

...
//code snippet to add to some function that you want to have close the tabs
        if (this.wManager) {
          var widgetCfg = this._getWidgetConfig('AttributeTable');
          if(widgetCfg){
            var attWidget = this.wManager.getWidgetByLabel(widgetCfg.label);
            if(attWidget){
              for(var t = attWidget.layerTabPages.length - 1; t >= 0; t--){
                attWidget.layerTabPageClose(attWidget.layerTabPages[t].paneId, true);
              }
            }
          }
        }
//end of code snippet

//support function
      _getWidgetConfig: function(widgetName){
        var widgetCnfg = null;
        array.some(this.wManager.appConfig.widgetPool.widgets, function(aWidget) {
          if(aWidget.name == widgetName) {
            widgetCnfg = aWidget;
            return true;
          }
          return false;
        });
        if(!widgetCnfg){
          /*Check OnScreen widgets if not found in widgetPool*/
          array.some(this.wManager.appConfig.widgetOnScreen.widgets, function(aWidget) {
            if(aWidget.name == widgetName) {
              widgetCnfg = aWidget;
              return true;
            }
            return false;
          });
        }
        return widgetCnfg;
      },‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
GilbertoMatos
Occasional Contributor II

Perfect Robert. Run fine as I need Thank you very much.

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Don't forget to mark this question as answered by clicking on the "Correct Answer" link on the reply that answered your question.