Inherit settings from another datatable?
Inherit settings from another datatable?
Hello!
I have a simple question regarding creating multiple tables. For instance, I have a table in which I translate some of the oLanguage attributes, as well as specify some other general settings (serverside, savestate etc).
Say I want to create another table using these same settings, is there a way to inherit these from the first table, or do I have to specify them for each table repeatedly?
Example:
$('#table1').DataTable({
"responsive": true,
"serverSide": true,
// etc..
$('#table2').DataTable({
"responsive": true,
"serverSide": true,
// etc..
I haven't found anything regarding this in the documentation, but maybe I'm just blind!
To clarify; I know how to instantiate multiple tables, I just want to know how to use the same settings for multiple tables that are processed server-side. I know it's possible clientside, basically you just use the same table with different data on the client.
Thanks for any explanation!
Cheers
This question has an accepted answers - jump to answer
Answers
This is actually a good question... I thought it would be easy with the
settings()
resource, but I wasnt able to pull it off.. :(Yea, I saw this function as well, but it doesn't seem to help in this matter. :/ The problem now is I get a lot of redundant code, since my tables are basically identic except for the columns, which I render in different ways depending on what table it is.
Does anyone have any suggestion on how to solve this? :)
The
settings()
method should be avoided if possible. It is the internal DataTables settings object - its properties can, will and do change between versions.Currently there is no why to inherit from an existing DataTable directly - however you could:
$.extend()
for each table.Allan
Thank you for your response Allan! I'll go ahead and use defaults.
Cheers for a great plugin