'targets' in columnDefs of Datatable
'targets' in columnDefs of Datatable
The documentation tells us the way we can use 'targets' in columnDefs. But is there any way we can use it dynamically? For example, I have a global array (containing column numbers) which I update every time certain function is carried out on datatable. I want to render those columns in the global array in a particular fashion. I need to know if there is any way in which I could do this.
"columnDefs":[
{
"targets": hide_them,//name of the global array
"render": //some function
}
]
Answers
Not quite like that - with the above, the
hide_them
array is evaluated only at intialisation time. You'd need to destroy and recreate the table to target different columns. Some operations can be done via the API - changing column visibility at run time for example. But changing the renderer for a column after initialisation is not possible at this time.Allan