bDestroy error?

bDestroy error?

bjornjubjornju Posts: 4Questions: 0Answers: 0
edited October 2010 in General
Hey all, total newbie here, so I probablyjust missed
something very easy.

Im using 1.7.3 and I need to redefine my table since a lot of
columns have changed (or is there a more dynamic way)?

When I try to use bDestry:true I get a a few different errors in datatables javascript impl:

1) Error 1,comes first time

[code]
oColumn is undefined
oSettings.aaSorting[i][1] = oColumn.asSorting[0]; jquery...bles.js (row 6627)
[/code]

2) error 2, comes each consequtove time:
[code]
oSettings.nTableWrapper is null
var nOrig = oSettings.nTableWrapper.parentNode; jquery...bles.js (row 2056)
[/code]

What I'm trying to to is the call below:

[code]
$('#datagrid').dataTable( {
"bDestroy" : true,
"aaData": [dummyData],
"aoColumns": cols
});

[/code]

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Could you also post how you generate 'cols' and 'dummyData'? In principle I don't see anything wrong here, or anything obvious that could be going wrong. The first error is likely due to unknown / incorrect columns - the second... that's got me guessing!

    Allan
  • bjornjubjornju Posts: 4Questions: 0Answers: 0
    Your question led me to the problem, I accidently called the initialization
    twice, first time with empty aoColumns (ie just 'new Array'), which
    is what causes the errors above.
    After that it does not seem to get back in shape even with proper
    initialization arguments. (Perhaps better validation should be added!?)

    Many thanks for your very,very fast response!

    // Bjorn
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Great to hear you've got it sorted. About the validation - you are passing bDestroy, which tell DataTables that you understand that it will reinitialise the table is needed, with the new parameters. Without it, DataTables would give a warning. However, it is possible you've found a case where the table is not 100% restored when using the destroy option. And ultimately yes, there should be a debug version of DataTables which includes a lot of debug and trace information (which can be stripped out for production sites) - it's on the to-do list, just need some time :-)

    Allan
  • bjornjubjornju Posts: 4Questions: 0Answers: 0
    Thanks for all your help, Allan! Really appreciate it!
    If you want me to, I could probably pinch down a very simple test page to display
    this issue, is that of interest?

    Also, similar, I notice that not all column headers are reset the way I expect:
    For example I start off with a 6 column table and via bDestroy create a 4 column table,
    then the headers of the remaining 2 columns (to the right , i.e. last) are still visible.

    I could file a forum post under bugs also for this, if anyone is interested, the setup
    is almost identical to the original problem.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Yes please, if you could put up a test page that would be really useful to know what is going on here.

    Thanks,
    Allan
  • bjornjubjornju Posts: 4Questions: 0Answers: 0
    edited October 2010
    Hera a simple complete snippet, excluding only inclusion of jquery + datatables script.

    In the below, with current, the remaining header issue is seen, column 4 and 5 should not be visible.

    If I, at row 39 below, change the for loop to go 0 loops instead of 3 (change from i < 3 to i <=0), the first reported
    issue is triggered.


    [code]






    a
    b
    c
    d
    e







    a1
    b1
    c1

    d1
    e1







    jQuery("#datagrid").dataTable()



    var cols = new Array();
    var dummyData = new Array ();

    for (var i = 0; i < 3; i++) {
    cols[i] = new Object();
    cols[i].sTitle = "Column " + i;
    dummyData.push("Colval: " + i)
    }

    $('#datagrid').dataTable( {
    "bDestroy" : true,
    "aaData": [dummyData],
    "aoColumns": cols
    });





    [/code]
This discussion has been closed.