Hide and show RDT columns programmatically


#1

Hi guys, i have an interesting problem with my RDT, I need to be able to hide and show RDT columns as needed but I don’t have any idea about how to do that, I saw in the documentation that it is possible to create the RDT with columns already hidden, but that is not the solution that I’m looking for, any idea or suggestion?


#2

Hi @davisg that’s so easy just let me show a piece of code:

let hide = function (event) {
        let rdt = cf.getVisualization('your_chart_id');
        rdt._visualization.gridOptions.columnApi.setColumnVisible('your_field', false)
};

let show = function (event) {
        let rdt = cf.getVisualization('your_chart_id');
        rdt._visualization.gridOptions.columnApi.setColumnVisible('your_field', true)
};

Remember that the RDT is an ag-grid based visualization. :man_technologist:


#3

Thanks @emoya I tried this solution the last week and it was just the solution I was looking for, thanks a lot, you saved my week :sunglasses: