sDom breaks my tables

sDom breaks my tables

DavidBDavidB Posts: 4Questions: 0Answers: 0
edited July 2012 in DataTables 1.9
Hi all,

I've run into an unusual problem with a data table. It works fine, however as soon as I attempt to put an 'sDom' attribute into the datatable object I encounter an error that prevents the data table loading. This is the initialization of data tables, as I mentioned if I remove the sDom variable it works fine.
[code]
var oTable = $('#cashbackTable').dataTable({
'bProcessing': true,
'bServerSide': true,
'sAjaxSource': 'myUrl',
'fnServerData': function(sSource, aoData, fnCallback)
{
aoData.push({'name': 'csrf_token', 'value': $('input[name="csrf_token"]').val()});
aoData.push({'name': 'view', 'value': 'cashback'});
$.ajax({
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
});
},
'aoColumnDefs' :
[
{'sClass' : 'c-ui-col1', 'aTargets' : [0, 2, 3, 4, 5, 6]},
{'sClass' : 'c-ui-col2', 'aTargets' : [1]},
],
'sPaginationType': 'full_numbers',
'sDom' : '<"c-ui-row"l>t'
});
[/code]

And the error I get in Firebug:
[code]
TypeError: c is undefined

...){if(a.oFeatures.bProcessing)for(var c=a.aanFeatures.r,d=0,g=c.length;d

Replies

  • allanallan Posts: 63,397Questions: 1Answers: 10,451 Site admin
    Which version of DataTables are you using? I've just tried it here ( http://live.datatables.net/atuyas/edit#javascript,html ) and it works as expected with 1.9.2.

    Allan
  • DavidBDavidB Posts: 4Questions: 0Answers: 0
    edited July 2012
    Hi Allan, we're using 1.9.2. It was a strange one but changing:

    [code]
    'sDom' : x
    [/code]

    to

    [code]
    "sDom" : x
    [/code]

    solved the problem, thanks for the code snippet!
  • allanallan Posts: 63,397Questions: 1Answers: 10,451 Site admin
    Very odd! But as long as it works...!

    Allan
  • sqtsqt Posts: 9Questions: 0Answers: 0
    edited August 2012
    I have the exact same problem. I changed from client-side data to ServerSide. sDom gives the exact same error as above. Changing single/double quotes did not give any results.

    Using jquery 1.72 and DataTables 1.9.2

    Using the full source, I can trace the problem to:

    Line 2896
    [code]
    var an = oSettings.aanFeatures.r
    [/code]
    an is undefined, the aanFeatures object only has t, aiDisplay and aiDisplayMaster, but no r object.
  • allanallan Posts: 63,397Questions: 1Answers: 10,451 Site admin
    Can you give us a link to a test page showing the problem please.

    Allan
  • sqtsqt Posts: 9Questions: 0Answers: 0
    Its an intranet website, but let me see if I can jsfiddle this.
  • sqtsqt Posts: 9Questions: 0Answers: 0
    I'm trying to reproduce at live.datatables.net, but I cannot use the example ajax source at http://datatables.net/release-datatables/examples/server_side/scripts/server_processing.php
    Can you add that datasource to the live.datatables.net website, so I can use it as a sAjaxSource feature?
  • allanallan Posts: 63,397Questions: 1Answers: 10,451 Site admin
    The path for the live site is slightly different: http://live.datatables.net/adikil/edit#javascript,html

    Allan
  • sqtsqt Posts: 9Questions: 0Answers: 0
    ok, reproduced!
    http://live.datatables.net/emaduy/5
  • zemmekkiszemmekkis Posts: 1Questions: 0Answers: 0
    Try adding the 'r' processing option into the sDom like:

    'sDom': 'ptr',

    If the r isn't there in the sDom and bProcessing is true then you get an undefined.
This discussion has been closed.