Hi,
I want to toogle columns in the treegrid component.
So I create a function to do that :
private toggleColumns(cols: TreeGridCol[]) {
const colsToHide = cols.filter(c => c.checked === false);
const colsToShow = cols.filter(c => c.checked === true);
if (this.treeGridObj) {
this.treeGridObj.grid.hideColumns(
colsToHide.map(v => v.field),
'field'
);
this.treeGridObj.grid.showColumns(
colsToShow.map(v => v.field),
'field'
);
}
}
colsToHide and colsToShow are lists defined by an other function.
For example
colsToHide: []
colsToShow: ["name", "site", "type"]
The function
toggleColumns
is cast when
colsToHide or
colsToShow changed.
But in the console I get this error :
core.js:6498 ERROR TypeError: Cannot read properties of undefined (reading 'hide')
at Grid.hideColumns (ej2-grids.es2015.js:15878:24)
Any idea ? Thanks or your help !