Include parameter in every datatables instance by default

Include parameter in every datatables instance by default

Alex3917Alex3917 Posts: 11Questions: 0Answers: 0
edited August 2013 in General
I am using datatables across a large number of views, and in each of them I am using the fnServerData parameter. Is it possible to automatically include this parameter by default when new tables are initialized, rather than cutting and pasting the line:

fnServerData: myFunction,

into the list of initialization parameters in every view?

Replies

  • Alex3917Alex3917 Posts: 11Questions: 0Answers: 0
    Oh wait, I see that there is there $.fn.dataTable.defaults that I can extend, which should do what I want.

    However, I have a couple tables that don't use serverside data. Will these break in any way if I include an fnServerData parameter in my defaults, or will it just not get called and otherwise work fine?
  • allanallan Posts: 63,514Questions: 1Answers: 10,472 Site admin
    It will work just fine :-) The server data function will only be called when needed.

    Allan
This discussion has been closed.