Select to view content in your preferred language

AttributeTable widget columns width

2013
8
Jump to solution
07-28-2016 07:55 AM
NatashaManzuiga
Regular Contributor

Hi all, is it possible to set columns width in the AttributeTable widget?

Thanks,

Naty

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Naty,

Remove that line that was left over from some other code trials.

View solution in original post

8 Replies
RobertScheitlin__GISP
MVP Emeritus

Naty,

  It is possible with a great deal of effort forethought on how you will handle this for each layer, etc.

It would be up to you to figure out where you would put this code and how you will determine the width of your fields.

First you would have to get a refference to the AT Widget.

var widgetCfg = this._getWidgetConfig('AttributeTable');

          if(widgetCfg){

            var attWidget = WidgetManager.getInstance().getWidgetByLabel(widgetCfg.label);

            //AT Widget fields have an id of "field0", "field1", etc the first value in the

            //resizeColumnWidth function is the column Id and then the width in pixels

            attWidget._activeTable.grid.resizeColumnWidth("field1", 200);

            this._fitColumns(attWidget._activeTable.grid);

          }

Support function:

_getWidgetConfig: function(widgetName){

        var widgetCnfg = null;

        array.some(WidgetManager.getInstance().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(WidgetManager.getInstance().appConfig.widgetOnScreen.widgets, function(aWidget) {

            if(aWidget.name == widgetName) {

              widgetCnfg = aWidget;

              return true;

            }

            return false;

          });

        }

        return widgetCnfg;

      },

0 Kudos
NatashaManzuiga
Regular Contributor

Hi Robert, I tried with your code but I get an error:
Cannot read property 'grid' of undefined and

In console, if I try to run attWidget._activeTable, I get undefined.

Thanks,

Naty

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Naty,

  That means that the code did not find the Attribute Table widget then. Do you have the AT Widget loaded in your app?

0 Kudos
NatashaManzuiga
Regular Contributor

Robert, that's the screenshot of Google Developer Tools.

Untitled.png

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Naty,

  Oh, Then you do not have a table that is active then.

0 Kudos
NatashaManzuiga
Regular Contributor

I can get _activeTable from this code:

var _activeTable=attWidget._tableFunctionController.getActiveTable();

then I can resize my column.

      if(widgetCfg){
        var attWidget = WidgetManager.getInstance().getWidgetByLabel(widgetCfg.label);
        //AT Widget fields have an id of "field0", "field1", etc the first value in the
        //resizeColumnWidth function is the column Id and then the width in pixels
        var _activeTable=attWidget._tableFunctionController.getActiveTable();
        _activeTable.grid.resizeColumnWidth("field1", 50);
        this._fitColumns(_activeTable.grid);
      }

but the last row...(this._fitColumns(_activeTable.grid);) doesn't work.

Thanks,

Naty

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Naty,

Remove that line that was left over from some other code trials.

ForrestBlack
Occasional Contributor

Hi Naty, 

I know it has been a long time since you wrote in this thread, but could you tell me where you put the get _activeTable code? I tried putting it in the _FeatureTable.js and also the Widget,js files, but neither seemed to work.

0 Kudos