Define a template configuration

Define a template configuration

jedrekjedrek Posts: 2Questions: 0Answers: 0
edited December 2009 in General
Hello!

I need make a template configuration for tables, for example:
[code]
// For all tables <-- template
$('.dataTables').dataTable({
'bProcessing': true,
'bStateSave': true,
'sPaginationType': 'full_numbers',
'language': 'configuration'
});

// For specific tables
$('#users_table').dataTable({
"aoColumns": [
null,
null,
null,
null,
{ "bSortable": false }
]
});[/code]

Or maybe I can create config array/object and pass them to the dataTable but how?
It is possible?

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Hi jedrek,

    You can't reinitialise the table - so don't think what you currently have would work quite right. What you could do is something like this:

    [code]
    // For all tables <-- template
    var obj = {
    'bProcessing': true,
    'bStateSave': true,
    'sPaginationType': 'full_numbers',
    'language': 'configuration'
    };

    // For specific tables
    var objCopy = jQuery.extend(true, {}, obj);
    objCopy.aoColumns = [
    null,
    null,
    null,
    null,
    { "bSortable": false }
    ];
    $('#users_table').dataTable( objCopy );
    [/code]
    Hope that helps,
    Allan
  • jedrekjedrek Posts: 2Questions: 0Answers: 0
    Hi allan,

    I am fully satisfied with this solution.
    Works perfectly so thanks :)
This discussion has been closed.