Configure Responsive Plugin with TypeScript
Configure Responsive Plugin with TypeScript

I'm setting up Angular DataTables with the Responsive plugin in my Angular app for the first time and it's not clear how to configure the Renderer using TypeScript. The example given is in JavaScript. I have created a template reference variable and called the DataTable function on it, but it gives an error that 'DataTable' doesn't exist on type 'ElementRef >any>'
this.dataTableID.DataTable({
responsive: {
details: {
renderer: $.fn.dataTable.Responsive.renderer.tableAll()
}
}
})
I also tried passing the renderer function as part of the dtOptions, but I get this build error: "Property 'Responsive' does not exist on type 'StaticFunctions'".
ngOnInit(): void {
this.dtOptions = {
responsive: {
details: {
renderer: $.fn.dataTable.Responsive.renderer.tableAll()
}
}
};
}
How do I convert this example to TypeScript for Angular?
Replies
We don't (yet) provide TypeScript typings for DataTables and its extensions. But you could try using the third party types.
Also you need to make sure that
this.dataTableID
is a jQuery object there.Allan