View Full Version : How to figure out which columns are hidden? [Solved]

18 Jun 2009, 6:46 AM
I have a grid with the custom filters plugin, and an export to excel feature. I want to the excel export to look exactly like the grid. I have it all working perfect, except I don't know how to figure out which columns are hidden, so I can pass which column not to export to excel...

This is what I am doing now:

buttons: [{
text: "Export",
tooltip: "Click here to export to Excel",
handler : function(){

18 Jun 2009, 6:50 AM
Loop through them, testing the isHidden method:-/

18 Jun 2009, 6:52 AM
Something like:

'&columns=' + grid.getColumnModel().findColumnsBy(function(c){return !c.hidden;}).join(',')

18 Jun 2009, 12:16 PM
Thank you both for you help. The code below works perfect for my usage:

I ended up using this code posted by mjlecomte:

Ext.override(Ext.grid.ColumnModel, {

* Returns an array of column config objects for the visibility given.
* @param {Boolean} hidden True returns visible columns; False returns hidden columns (defaults to True).
* @param {String} cfg Specify the config property to return (defaults to the config).
* @return {Array} result
getColumnsVisible : function(visibility, cfg){
var visible = (visibility === false) ? false : true;
var r = [];
for(var i = 0, len = this.config.length; i < len; i++){
var c = this.config[i];
var hidden = c.hidden ? true : false;
if(hidden !== visible){
r[r.length] = c[cfg] || c;
return r;


Grid.getColumnModel().getColumnsVisible(true, 'dataIndex')