row.add() error - Requested unknown parameter
row.add() error - Requested unknown parameter
I'm sure everyone's familiar with this. I'm doing a ground up rebuild of an old project and have previously used datatables with great success!
Unfortunately, having an issue with something that seems super simple, hopefully it's just a simple syntax screw up.
HTML table & Initialization:
<table cellspacing="0" id="orderBox" class="">
<thead>
<tr>
<th class="orderBoxQty">Qty</th>
<th class="orderBoxItem">Item</th>
<th class="orderBoxPrice">Price</th>
<th class="orderBoxCourse">Course</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
</tfoot>
</table>
...
$(document).ready( function () {
$('#orderBox').DataTable( {
select: {
style: 'multi'
},
paging: false,
ordering: false,
searching: false,
language: {
info: "",
infoEmpty: "",
select: {
rows: ""
}
},
} );
} );
HTML div:
<div onclick="addItemToOrderBox(this)" class="item doubleWidth posButton" data-name="Burger" data-price="12" data-printGroup="Mains">
<img src="https://i2.wp.com/freepngimages.com/wp-content/uploads/2016/11/bacon-burger.png" />
<a>Burger</a></div>
Javascript:
var globalQty = 1;
function addItemToOrderBox(button){
button = $(button).data();
orderBox = $('#orderBox').DataTable();
itemQty = globalQty;
itemName = button['name'];
itemPrintGroup = button['printGroup'];
itemPrice = button['price'] * itemQty;
orderBox.row.add([itemQty,itemName,itemPrice,itemPrintGroup]).draw();
}
The error received
DataTables warning: table id=orderBox - Requested unknown parameter '3' for row 0, column 3. For more information about this error, please see http://datatables.net/tn/4
The addrow function successfully adds data to the first 3 columns but leaves the fourth empty, which aligns with the error, but I'm not sure what I'm doing wrong.
Answers
Debug code jgebic if that helps anyone!
Seemed to just be an issue with using camelCase in the data attribute name.