Setup default settings

Setup default settings

Vilhelm PerssonVilhelm Persson Posts: 11Questions: 0Answers: 0
edited January 2011 in General
Hi
I use DataTables on several pages and want to setup some default configuration that is used on all pages.
I have tried setup the dataTableSettings in a global include file but I am not able to get it to work
[code]$.fn.dataTableSettings = ( {"bPaginate":true,"bFilter": true,"bSort": true,"iDisplayLength":10,"sPaginationType": "full_numbers"} );[/code]

And then on the page do
[code]$('#ID_myTable').dataTable( {
"aaSorting": [[ 0, "asc" ]],
"iDisplayLength":25
});[/code]

But I am not able to get it to work and dont know if
- it is that I am doing something wrong in the code?
- seting wrong default parameter (dataTableSettings)?
- if is not possible?

I guess I can change my code to something
* Setup my own global settings structure.
* Setup local settings
* Use jQuery.extend
* Pass the extended object into the dataTable()
But that dont see to be the "right" way to solve it.

Best regards
Vilhelm Persson

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    It is not currently possible to set default values of DataTables, other than by changing the source code. This will be addressed in a future revision at some point. Until then what you can do is define your default initialisation object, then extend it with any customisations just prior to each table's initialisation and pass the extended object in.

    Allan
  • rh0diumrh0dium Posts: 14Questions: 0Answers: 0
    Allan is this still valid. http://datatables.net/beta/1.9/examples/advanced_init/defaults.html?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    No this post is no longer valid - DataTables 1.9 introduces the ability to set defaults:
    http://datatables.net/new/1.9
    http://datatables.net/release-datatables/examples/advanced_init/defaults.html

    Allan
This discussion has been closed.