Use of dataTables Globals

Use of dataTables Globals

jdadwilsonjdadwilson Posts: 127Questions: 30Answers: 1

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

  • kthorngrenkthorngren Posts: 21,336Questions: 26Answers: 4,951
    edited July 3

    See the Setting defaults docs. This will apply to all Datatables that initialize after the defaults setting executes. It also states this:

    This object takes all of the same parameters as the DataTables initialisation object, but in this case you are setting the default for all future initialisations of DataTables.

    can I include the initComplete and drawCallback area in the global file?

    Yes, you can define initComplete and rowCallback in the default settings, like this:
    https://live.datatables.net/rokiqiye/1/edit

    Also, if so, can initComplete and drawCallback code be added in the main dataTable area to expand on the items from the global area?

    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

  • jdadwilsonjdadwilson Posts: 127Questions: 30Answers: 1

    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

Sign In or Register to comment.