bStateSave:true causes DataTable to fail in some cases

bStateSave:true causes DataTable to fail in some cases

AntikonAntikon Posts: 6Questions: 0Answers: 0
edited January 2010 in General
Hi Allan.

I've one table on page 'site.com/admin?mode=1' and one on page 'site.com/admin?mode=2'. These tables have different numbers of columns (for example, 3 for the first table and 5 for the second). Both of tables initialized with "bStateSave": true and suitable "aoColumns".

The problem is that when you sort the 5th column in the second table and after it you go to the first page Datatable fails. This is due to 'SpryMedia_DataTables_0_admin' cookie (and, I think, "aaSorting" variable) that was stored by the second page.

How can I solve this issue?

And, by the way, I've a suggestion that Datatable should throw an exception or alert when it's not properly initialized (for example, if in the section missed or you had described more "aoColumns" that table really has) instead of 'oSettings.aoData[i]._aData[iCol] is undefined' javascript error.

Best regards,
Antikon

Replies

  • allanallan Posts: 63,407Questions: 1Answers: 10,452 Site admin
    Hi Antikon,

    The problem with the cookie is because of the ?mode=x variable. DataTables only uses the path (window.location.pathname) to save the cookie. One option might be to set a different ID on the table depending on the mode variable - but beyond that it would require a little modification of the DataTables core code. URL re-writing is another option worth considering.

    Regarding the alert/exception - yes I full agree. I'd really like to spend some time and build a 'debug' version of DataTables will will give useful trace and debug information, and the 'production' version can then be used for a live site. However, I've just not got enough time to do this at the moment, given that it takes a couple of hours a day just to keep up with support requests, never mind new development! It's on the to-do list for some point in the future.

    Regards,
    Allan
This discussion has been closed.