Marta Molinari
Marta Molinari

Reputation: 13

Ag-grid hidden columns - Angular2

I want to add a message when I hide a column by ToolPanel or by columnsMenu.

How can I know which column is hidden?

I know which columns are hidden only when I load the grid by gridOptions.columnApi.getColumnState() but I don't know what the method or event is to know in realtime which column I have hidden.

Upvotes: 1

Views: 1199

Answers (1)

Jarod Moser
Jarod Moser

Reputation: 7358

There is the onColumnVisible event that you can listen to. If I'm reading the event hierarchy correct at the bottom, then you will be given the column or columns that were affected and whether or not they were hidden.

this.gridOptions.onColumnVisible = function (event) {
    if (event.visible) {
        console.log(event.column.colId + ' was made visible');
    } else {
        console.log(event.column.colId  + ' was hidden')
    }
} 

Upvotes: 2

Related Questions