Mosquito
Mosquito

Reputation: 48

ExtJS 4: How can I get all grid columns in current order?

When I use grid.columns it returns all columns from grid (visible or not), but it's not in current order..

Then I tried grid.getView().getGridColumns() and it returned the columns in current order, but only the visible ones.

How can I get all columns, visible and not visible, in current order?

Upvotes: 3

Views: 5063

Answers (2)

bigMC28
bigMC28

Reputation: 441

I had the opposite problem as I need only the visible ones. For all columns grid.columns seems like the easiest way (since 2.3). I then put them in a map by name because I needed to access row cells:

var headerColumns = myGrid.columns;
var headerMap = {};
//put them in a map of name, index
Ext.each(headerColumns, function(headerColumn, i) {
  headerMap[headerColumn.dataIndex] = i;
});

Upvotes: 1

prsmax
prsmax

Reputation: 223

you can try

grid.down('headercontainer').getGridColumns();

returns visible and non-visible columns

grid.down('headercontainer').getVisibleGridColumns();

returns only visible columns

Upvotes: 3

Related Questions