Use of dataTables Globals
Use of dataTables Globals
Given that each of my 8 sites (4 main, 4 admin) contains over 50 dataTables instances and to ensure each appears the same I created a dataTables_globals.js file which loads after the datatable-2.0.js file.
One of the first things I learned from my FORTRAN 2 professor was... "If you do something more than twice, make it a function." Thus, my global file.
So the question is... can I include the initComplete and drawCallback area in the global file? If so, how exactly? Also, if so, can initComplete and drawCallback code be added in the main dataTable area to expand on the items from the global area?
Sometimes after the initComplete I need to do additional work on the records of the table.
Let me know if you need some additional information.
As always,,, thanks!
jdadwilson
Answers
See the Setting defaults docs. This will apply to all Datatables that initialize after the defaults setting executes. It also states this:
Yes, you can define
initComplete
androwCallback
in the default settings, like this:https://live.datatables.net/rokiqiye/1/edit
Datatables doesn't provide a way to merge settings in the default settings with settings defined in the individual Datatables options. The individual options will overwrite the default settings.
Kevin
I added the initComplete and drawCallback code to the global file. Worked great. Now need to determine if that is the best solution.
I think I am out of questions for the present. Will probably come across some others in the near future.
Thanks for all your help!!
jdadwilson