Datatables TypeError: c is undefined

后端 未结 9 1372
[愿得一人]
[愿得一人] 2020-12-03 09:20

I try to use jQuery DataTables but I get the error

TypeError: c is undefined

I don\'t know what is wrong with my code as I can s

相关标签:
9条回答
  • 2020-12-03 09:59

    In my case th and td , count is not equal due do colspan, removed colspan and it worked.

    0 讨论(0)
  • 2020-12-03 10:02

    in my case, i had to remove colspan attribute from a th inside thead and get rid of the error ;(

    0 讨论(0)
  • 2020-12-03 10:08

    In my case, missing aaData in sever side return result.

    //Javascript
    $('#table').DataTable({
            sAjaxSource: '/load',
            aoColumns: [
             ...
            ],
    });
    //server side(in Rails)
    render json: {'aaData'=>data}
    
    0 讨论(0)
  • 2020-12-03 10:10

    In my case, I got the same error because I used the ajax.dataSrc( data ) function to manipulate the data. But after that i forgot to return the data.

    "dataSrc": function ( json ) {
      for ( var i=0, ien=json.data.length ; i<ien ; i++ ) {
          //somethings...
      }
      return json.data;// I forgot this line, then i got the error "TypeError: c is undefined"
    }
    

    After a few minutes, I checked the documentation of the ajax.dataSrc function and I noticed that I did not have the return:

    Returns: array. Array of data that DataTables is to use to draw the table

    I hope you do not have the same distraction...

    0 讨论(0)
  • 2020-12-03 10:11

    In my case, my front-end: ajax: { dataSrc: "data" } was OK, but on server-side I returned object where first letter was Upper return Json(new { Data = model });

    0 讨论(0)
  • 2020-12-03 10:15

    Another day, another solution - this time caused by a style sheet!

    After spending hours reducing a gigantic web page to the raw charts code, I found that this error shows (for pie charts) when CSS rules for fonts in the stylesheet contain the calc function.

    In our style sheet, this line of code:

    html {
      font-size: calc(12px + 5%);
    }
    

    ...broke the chart. We needed this because our webfont wasn't resizing smoothly and needed a size slightly larger than 12px but smaller than 13px, and this trick forced a better resize.

    Overwriting the style rule on the chart widget directly solved the issue:

    CSS

    html {
      font-size: calc(12px + 5%);
    }
    .widget {
       font-size: 12px /* Replace the above rule */;
    }
    

    JS

    var GoogleChart1 = new google.visualization.PieChart(document.getElementById('Chart1'));
    

    HTML

    <div id="Chart1" class="widget"></div>
    
    0 讨论(0)
提交回复
热议问题