In my Typescript constructor, I am working on constructing a datatable with properties like 'orderable', 'data' and 'name'. One thing I'm trying to figure out is how to control the visibility of one column based on the value of another column in the same row.
I experimented with the 'render' method which allowed me to modify the text. However, I found that only setting it to an empty string ('') was not satisfactory. What I really want is to hide the column altogether using something like 'visible: false'. Below is an example with some existing code in the constructor:
data: 'ColumnData',
name: 'ColumnName',
orderable: false,
visibility: /*insert logic here*/,
render: (data: any, t: string, row: any, meta: DataTables.CellMetaSettings) => {
switch (row['ColumnThatThisOneDependsOn']) {
case 1:
return ``;
default:
return `<div>${data}</div>`;
}
}
My goal is to be able to dynamically change the visibility of the 'ColumnName' column (either to 'true' or 'false') based on the value of the 'ColumnThisOneDependsOn' column. Any insights or guidance on how to achieve this would be greatly appreciated!