State saving does not work: "TypeError: oColumn is undefined" (line 6705)

State saving does not work: "TypeError: oColumn is undefined" (line 6705)

MiBMiB Posts: 15Questions: 0Answers: 0
edited February 2013 in Bug reports
Hi Allan,

I am trying to use the datatable as a replacement for rich:extendedDataTable. Most of the features are working, except for state saving. I always get:

TypeError: oColumn is undefined
https://localhost:8443/js/jquery.dataTables.js
Line 6705

using DataTables 1.9.4. My table initialization:
[code]
var siTable = jQuery('#table').dataTable( {
"bPaginate": false,
"bInfo" : false,
"bAutoWidth" : true,
"aoColumnDefs" : [
// do not display the internal id and status id columns
{ "bSearchable": false, "bVisible": false, "aTargets": [ "ID", "STATUS_ID" ] },
// when sorting the Status column, use the internal status id column
{ "iDataSort": [ 1 ], "aTargets": [ 2 ] }
],
"aaSorting": [[2,'desc']], // initial sorting by status column
"bStateSave" : true,
"sDom" : 'TRlrt',
"oTableTools" : {
"aButtons": [],
"sRowSelect": "single",
"sSelectedClass": "selected",
"fnRowSelected": function (nodes) {
// ....
}
}
});
[/code]

Cookies are enabled.
I'd be grateful for any hint. I still didn't find the time to update the colReorderResize thing... too much to do.

Replies

  • allanallan Posts: 61,669Questions: 1Answers: 10,096 Site admin
    Can you link to a test case please? Are you using the latest nightly of ColReorder?

    Allan
  • MiBMiB Posts: 15Questions: 0Answers: 0
    No, I am using ColReorder 1.0.8. And I forgot to say, I am using jQuery 1.4. How can I link to a test case? I don't have a public server... (yet).
  • allanallan Posts: 61,669Questions: 1Answers: 10,096 Site admin
    Can you try using the latest ColReorder nightly? Also, try deleting the cookie and then reloaded the page to see if it was a stale cookie that was the problem.

    Allan
  • MiBMiB Posts: 15Questions: 0Answers: 0
    Ok, I had to replace all .on()/.off() calls with .bind()/.unbind() but, alas, same result, same error message... I am trying to upload an example to jsfiddle, dunno if that will work, though.
  • MiBMiB Posts: 15Questions: 0Answers: 0
    jfiddle doesn't do it, sorry. But here is a complete example that triggers the problem - note the inclusion of prototype, without which is does work fine:

    [code]
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">




    DataTables state








    jQuery.noConflict();

    jQuery(document).ready(function() {
    jQuery('#example1').dataTable( {
    "bPaginate": false,
    "bInfo" : false,
    "bAutoWidth" : true,
    "aoColumnDefs" : [
    // do not display the internal id and status id columns
    { "bSearchable": false, "bVisible": false, "aTargets": [ "ID", "STATUS_ID" ] },
    // when sorting the Status column, use the internal status id column
    { "iDataSort": [ 1 ], "aTargets": [ 2 ] }
    ],
    "aaSorting": [[2,'desc']], // initial sorting by status column
    "bStateSave" : true,
    "sDom" : 'TRlrt',
    "oTableTools" : {
    "aButtons": [],
    "sRowSelect": "single",
    "sSelectedClass": "selected",
    "fnRowSelected": function (nodes) {
    alert("yes");
    }
    }
    });
    });










    Status
    Site ID
    Region
    Op. Mode
    Alarm
    Batt SOC
    Fuel level(l)
    Fuel level(%)
    Predicted refill
    Next maintenance
    Env. Temp.
    Last Life Signal




    120
    3

    Lab-TS08

    genset
    solar_panel
    80.4
    7.9
    78.5
    2013-02-15
    2013-02-15
    79.9
    2013-02-15 14:01:19



    264
    3

    Lab-TS03
    Laboratory 1
    active
    failed
    100.0
    0.0
    0.0
    N.A.
    2013-02-15
    25.0
    2013-02-15 14:00:55








    [/code]
  • allanallan Posts: 61,669Questions: 1Answers: 10,096 Site admin
    Oh - it works without prototype? Have you tried the nightly of TableTools as well? There was an issue there that might be related... Any Javascript errors on the console other than that?

    Allan
  • MiBMiB Posts: 15Questions: 0Answers: 0
    No, even with TableTools nightly, ColReorder nightly, it doesn't work. There are no other errors besides the one in line 6705.

    And yes, it does work without prototype, but I have to delete the cookie first.... errm.. I have an idea: prototype causes the cookie to break, that's it! Here is the cookie without prototype:

    [code]
    {"iCreate":1361473506582,"iStart":0,"iEnd":2,"iLength":10,"aaSorting":[[2,"desc",1]],"oSearch":{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true},"aoSearchCols":[{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true},{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true},{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true},{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true},{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true},{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true},{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true},{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true},{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true},{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true},{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true},{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true},{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true},{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true}],"abVisCols":[false,false,true,true,true,true,true,true,true,true,true,true,true,true],"ColReorder":[0,1,2,3,4,5,6,7,8,9,10,11,12,13]}
    [/code]

    and this is the cookie after it gets stored with prototype loaded:

    [code]
    {"iCreate":1361473550279,"iStart":0,"iEnd":2,"iLength":10,"aaSorting":"[[2, \"desc\", 1]]","oSearch":{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true},"aoSearchCols":"[{\"bCaseInsensitive\": true, \"sSearch\": \"\", \"bRegex\": false, \"bSmart\": true}, {\"bCaseInsensitive\": true, \"sSearch\": \"\", \"bRegex\": false, \"bSmart\": true}, {\"bCaseInsensitive\": true, \"sSearch\": \"\", \"bRegex\": false, \"bSmart\": true}, {\"bCaseInsensitive\": true, \"sSearch\": \"\", \"bRegex\": false, \"bSmart\": true}, {\"bCaseInsensitive\": true, \"sSearch\": \"\", \"bRegex\": false, \"bSmart\": true}, {\"bCaseInsensitive\": true, \"sSearch\": \"\", \"bRegex\": false, \"bSmart\": true}, {\"bCaseInsensitive\": true, \"sSearch\": \"\", \"bRegex\": false, \"bSmart\": true}, {\"bCaseInsensitive\": true, \"sSearch\": \"\", \"bRegex\": false, \"bSmart\": true}, {\"bCaseInsensitive\": true, \"sSearch\": \"\", \"bRegex\": false, \"bSmart\": true}, {\"bCaseInsensitive\": true, \"sSearch\": \"\", \"bRegex\": false, \"bSmart\": true}, {\"bCaseInsensitive\": true, \"sSearch\": \"\", \"bRegex\": false, \"bSmart\": true}, {\"bCaseInsensitive\": true, \"sSearch\": \"\", \"bRegex\": false, \"bSmart\": true}, {\"bCaseInsensitive\": true, \"sSearch\": \"\", \"bRegex\": false, \"bSmart\": true}, {\"bCaseInsensitive\": true, \"sSearch\": \"\", \"bRegex\": false, \"bSmart\": true}]","abVisCols":"[false, false, true, true, true, true, true, true, true, true, true, true, true, true]","ColReorder":"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]"}
    [/code]

    Prototype makes the array a string?! Well, I guess you will be more qualified to analyse it :-)
  • allanallan Posts: 61,669Questions: 1Answers: 10,096 Site admin
    Are you using the latest version of Prototype? It sounds like it is doing something bad to JSON.stringify... Might not be an issue I can fix that one, if it is.

    Allan
  • MiBMiB Posts: 15Questions: 0Answers: 0
    No, as you can see from the example above, I am using prototype-1.6.0.3.js - it is the one I am stuck with because it comes with RichFaces 3.3.3. If JSON.stringify is the reason I might be able to overwrite that definition, I will have a look.
  • MiBMiB Posts: 15Questions: 0Answers: 0
    Darn... it works with prototype 1.7.0. I found
    "Make Prototype's JSON implementation EcmaScript 5 compliant."
    in prototype's changelog. So I will try to replace the stringify and report back with the result in a bit.
  • MiBMiB Posts: 15Questions: 0Answers: 0
    Took me a while because I had to replace Prototype in all of RichFaces - I recompiled the whole thing. And I have to say - it works perfectly now. So this was indeed a Prototype bug.
  • allanallan Posts: 61,669Questions: 1Answers: 10,096 Site admin
    Good to hear you have it working now.

    Allan
This discussion has been closed.