[closed-fake] one page, several datatables => cross-instances settings persistence

[closed-fake] one page, several datatables => cross-instances settings persistence

emriemri Posts: 2Questions: 0Answers: 0
edited August 2011 in Bug reports
Hello,

I experiment the following problem: some settings defined in one instance are defined identically in the second one.

I have 2 datatables on the same page, each has very differents settings and initialized like that:

The first one (notice the bVisible to false in aoColumnDefs setting):

[code]
$('#table1').dataTable($.extend(true, es.dataTableSettings, {
"bProcessing": true,
"bSortable": false,
...
"aoColumnDefs": [
{ "mDataProp": "documentOrder" ,"aTargets": [0]},
{ "mDataProp": "fileName" ,"aTargets": [1]},
{ "mDataProp": "fileTitle" ,"aTargets": [2]},
{ "bVisible": false, "mDataProp": "documentId","aTargets": [3]},
]
...
}));
[/code]


The second one:
[code]
$('#histo_tab').dataTable( $.extend(true, es.dataTableSettings, {
"bProcessing": false,
"bSortable": false,
"bFilter": false,
...
"sAjaxDataProp": "records",
"aoColumnDefs": [
{ "mDataProp": "status" ,"aTargets": [0]},
{ "mDataProp": "dateFormatted" ,"aTargets": [1]},
{ "mDataProp": "actor" ,"aTargets": [2]},
{ "mDataProp": "details","aTargets": [3]},
],
....
}));
[/code]

Using this order when applying datatables results in the 4th column in second datatable to be hidden (debugging code show me that the settings bVivible is set to false in the settings of the second datatable).

Inverting the initialisation of the datatables resolves the problem.

I deduced that some settings seems to be persistent between differents datatable instances.


Did I miss something or is that a real bug ?

Regards,
emri99

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    edited August 2011
    why are you using extend()? this is what's bringing in values from elsewhere. I don't think there's any link between the table settings otherwise.

    [quote]
    Keep in mind that the target object (first argument) will be modified, and will also be returned from $.extend(). If, however, we want to preserve both of the original objects, we can do so by passing an empty object as the target:
    [/quote]

    in addition to returning a merged object, the TARGET object is also modified (es.dataTableSettings)

    if you want to avoid polluting your original object, use a blank object literal (or the expression "new Object") as the first arg
    [code]
    $.extend(true, { }, es.dataTableSettings, {
    // ...
    [/code]
  • emriemri Posts: 2Questions: 0Answers: 0
    damned !

    thanks for pointing this out :)
    I know that but I miss it here ! need to sleep :D

    thx again ;)
This discussion has been closed.