Responsive extension, column controls & serverside ajax= Requested unknown parameter '0' for row 0.

Responsive extension, column controls & serverside ajax= Requested unknown parameter '0' for row 0.

kmd1970kmd1970 Posts: 36Questions: 8Answers: 1
edited July 2015 in Free community support

I am using JQuery 1.11.2, Datatables 1.10.7 and Responsive extension 1.0.6.

References:
https://www.datatables.net/extensions/responsive/examples/child-rows/column-control.html
https://www.datatables.net/extensions/responsive/examples/initialisation/ajax.html

I am trying to use the responsive extension with left side controls in their own column and server side.

However, I get the Requested unknown parameter '0' for row 0. error whenever i refresh the page.

<table id="example" class="table display dt-responsive nowrap" cellspacing="0" width="100%">
      <thead>
    <tr>
          <th></th>
          <th>Name</th>
          <th>Position</th>
          <th>Office</th>
          <th>Extn.</th>
          <th>Start date</th>
          <th class="none">Salary</th>
        </tr>
  </thead>
    </table>
 
<script>

    $(document).ready(function() {
    $('#example').DataTable( {
        "ajax": "modules/setting/views/data.txt",
         responsive: {
            details: {
                type: 'column'
            }
        },
        order: [ 1, 'asc' ],
        "columns": [
            { className: 'control', orderable: false, targets:   0 },
            { "data": "name" },
            { "data": "position" },
            { "data": "office" },
            { "data": "extn" },
            { "data": "start_date" },
            { "data": "salary" }
        ]
    } );
} );
    </script>

EDIT: OK, I think I figured two ways around the error :

  1. Use a render
  var controls = function(data, type, row, meta) {  
       return null;     
    };  

   "columns": [
            { className: 'control', orderable: false, targets:   0, render : controls },
            { "data": "name" },
            { "data": "position" },
            { "data": "office" },
            { "data": "extn" },
            { "data": "start_date" },
            { "data": "salary" }
        ] ....

or

  1. Use "data": null, "defaultContent": ""
   "columns": [
            { "data": null, "defaultContent": "", className: 'control', orderable: false, targets:   0 },
            { "data": "name" },
            { "data": "position" },
            { "data": "office" },
            { "data": "extn" },
            { "data": "start_date" },
            { "data": "salary" }
        ] ....

Replies

  • allanallan Posts: 61,710Questions: 1Answers: 10,103 Site admin

    The second method is the way I would suggest myself.

    Allan

  • kmd1970kmd1970 Posts: 36Questions: 8Answers: 1

    Thanks Allan. Keep up the good work. Hope you've made a million dollars from Datatables by now. :)

  • allanallan Posts: 61,710Questions: 1Answers: 10,103 Site admin

    One can wish :-)

    It is good fun tho!

    Allan

This discussion has been closed.