Angular 9 / Typescript - Hiding columns
Angular 9 / Typescript - Hiding columns

I'm trying to hide a column. My file (component.ts) looks something like this:
myValues: any; // Can it be DataTables.ColumnSettings = {} ?
dtOptions: DataTables.Settings {};
this.myValues = [ {data: 'valueId' }, {data, 'myValue'} ];
this.dtOptions = {
...
columns: this.myValues,
columnDefs: [ orderable: true, targets: [_all] }
...
};
In node modules -> @types -> datatables.net -> index.d.ts, there is a ColumnsSetting interface with a visible property. However, when adding that to the dtOptions object it raises an error; also it doesn't provide details on where to apply.
How can I hide the first column?
The references I've found on this site are only for JS. Is there a place where I can find documentation for TS?
This discussion has been closed.
Answers
The
columns
docs state that it expects and array. Looks like you are trying to use an object.What is the error?
Looks like you have a syntax error with
{data, 'myValue'}
. It should be a colon like this{data: 'myValue'}
.The
columnDefs.targets
docs state that_all
is to be a string. You should havetargets: ["_all"]
.Kevin