Setting bStateSave to true = asSorting error

Setting bStateSave to true = asSorting error

SojborgSojborg Posts: 17Questions: 0Answers: 0
edited September 2012 in General
Hi,

We have been using an older version (v. 1.7.6) of DataTables for a while and now we want to upgrade to the newest version (v. 1.9.4).

It all works great except that if we turn on bStateSave on we get this error:

[code]Uncaught TypeError: Cannot read property 'asSorting' of undefined jquery.dataTables.min.js:5953
_that jquery.dataTables.min.js:5953
p.extend.each jquery.js:2
p.fn.p.each jquery.js:2
DataTable jquery.dataTables.min.js:5652
DataTable.LoadTable datatable.js:105
jQuery.ajax.success datatable.js:62
p.Callbacks.k jquery.js:2
p.Callbacks.l.fireWith jquery.js:2
y jquery.js:2
p.support.ajax.p.ajaxTransport.send.d[/code]

Turning bStateSave off again makes the error go away.

We are initializing the DataTables like this:

[code]
jQuery(_target).dataTable({
"bStateSave": true,
});
[/code]

Unfortunally i can not link to an example page because the system runs on the intranet.

Any ideas on how to fix this?

Replies

  • SojborgSojborg Posts: 17Questions: 0Answers: 0
    No one who can help me here?
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    You need to tell us how we can reproduce the error so we can at least see the issue, never mind how to actually fix it.

    As the 'new thread' information says:

    > Do: Use DataTables live or JS Fiddle if you can't link to your own page.

    Allan
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    And use the debugger as well :-)
  • SojborgSojborg Posts: 17Questions: 0Answers: 0
    Hi Allan,

    Thank you for your reply. I have put together an example here:

    http://188.120.94.188/tvisinfotest/datatabletest.asp

    First time you load the page it properly won't fail, but then try to do some bStateSave stuff like changing the number of rows to show and then reload the page. This will give you the error described in topic.

    Looking forward to your reply on this.
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    It looks like the JSON is either being double escaped for the state save or not being unescaped full. Are you using any state saving callbacks? I can't actually see where the init of DataTables is done as it appears to be encapsulated.

    I'd really suggest stripping back the page to simplify the issue - there is a huge amount of Javascript on that page and it is possible there is a conflict somewhere. And even if not, it will simplify hugely.

    Allan
  • SojborgSojborg Posts: 17Questions: 0Answers: 0
    Hi,

    I simplified the page back to the simplest possible, but i still get the error. I have updated the test paged that i linked to above, if you could take a look again?

    Now the DataTables is initialised directly at the linked page and isn't encapsulated.
  • SojborgSojborg Posts: 17Questions: 0Answers: 0
    Okay, just cleared the cache and now it works on the simplified version. I will try solving it from here. Thank you for your suggentions.
This discussion has been closed.