This example was made in response to a user’s request. It shows how to hide a table column that has no data in it. The column filter can be modified for different purposes.
Use the postQuery hook (available in the Table Builder) #
((table) => {
// Put the column to be filtered in place of columnName.
let rows = table.instance.getRowModel().rows
// wpda.log.info(rows)
if (rows) {
let filteredRows = rows.filter(r => r.original.columnName === null)
// wpda.log.info(filteredRows)
if (filteredRows.length === 0) {
table.instance.setColumnVisibility({ columnName: true })
} else {
table.instance.setColumnVisibility({ columnName: false })
}
}
})