0

I have a trouble about hiding columns in a Grid at runtime.

In a project I use a function that returns the configuration of a column in a Grid. For take the list of my columns in the Grid I use this piece of code:

var cmV = cmpGrid.getView(); var cmH = cmV.getHeaderCt(); var cm = cmH.getGridColumns();

The variable "cm" returns an array with the configured columns in the grid.

When I manually hide a column with the "column" option in the header Grid with ExtJS version 3.4.1 I can get the property

hidden:true

for the configured column. But with ExtJS 6 the configured column doesn't include this property.

How I can resolve this issue?

Thanks at all in advance, Lorenzo.

**

UPDATE

** I have discovered this about my previous question. With

var cm = cmH.getGridColumns();

I can get the array of the columns in the grid. Analyzing this array with Firebug I had found the subarray "config" that contains the properties required by the columns for the configuration. However now this array doesn't reflect more the changed configuration of a column but the default configuration applied. My first question is if this new behavior is a bug or not. Because I have found this new behavior I have changed my code to get the properties of a column not from the subarray config but from the radix. However now the possible configurations are so much. Now my second question is if there is a way to reduce or to have only the principal properties for type of columns in a grid.

Lorenzo
  • 200
  • 2
  • 13

1 Answers1

0

Why not just use grid.columns[index].setHidden(true) ?

Or if you want to take the list of columns, how about reconfigure columns.

var tempColumns = [];

// "cm" returns an array with the configured columns in the grid
cm.forEach(function(e) {
    if (some conditions) {
        tempColumns.push({
            xtype: e.xtype,
            text: e.text,
            dataIndex: e.dataIndex,
            hidden: true,
            width: e.width,
            align: e.align,
            format: e.format
        });
    }
    else{
        tempColumns.push({
            xtype: e.xtype,
            text: e.text,
            dataIndex: e.dataIndex,
            hidden: e.hidden,
            width: e.width,
            align: e.align,
            format: e.format
        });
    }
});

grid.reconfigre(null, tempColumns);

https://fiddle.sencha.com/#fiddle/17lq

Yasuyuki Uno
  • 2,417
  • 3
  • 18
  • 22
  • Hi @Yasuyuki Uno. Thanks for this reply. But I cannot construct my column configs in this way. I must construct the column config with properties setting at runtime by ExtJS. – Lorenzo Mar 24 '16 at 16:24