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.
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 :
- 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
- 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
The second method is the way I would suggest myself.
Allan
Thanks Allan. Keep up the good work. Hope you've made a million dollars from Datatables by now. :)
One can wish :-)
It is good fun tho!
Allan