i have an issue with cell().data()
i have an issue with cell().data()
varshnage
Posts: 2Questions: 0Answers: 0
var table = $("#productlist tr.selected td:nth-last-child(2)").DataTable();
$('#partTermSearch tbody').on('click', 'button', function () {
var currow = $(this).closest('tr');
var ptID = currow.find('td:eq(1)').text();
var ptName = currow.find('td:eq(4)').text();
var result = ptID + ' - ' + ptName;
table.cell().data(result).draw();
var row = {
partTermID: ptID,
partTermName: ptName,
flag: 1
};
UpdateRowData(row);
});
i get the error on line table.cell().data(result).draw();
the error is - Unhandled exception at line 130, column 358 in https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js
0x800a138f - JavaScript runtime error: Unable to get property '0' of undefined or null reference
how do i resolve this problem?
This discussion has been closed.
Replies
You probably need to provide a
cell-selector
as noted in thecell()
documentation. Maybe something like this:table.cell( $(this) ).data(result).draw();
Kevin
Thanks for reply @ Kevin
Still it gives same runtime error
Is there any need to add additional library for cell().data
No - its built into DataTables core.
What selector did you use?
table.cell()
isn't actually selecting any cell, like Kevin said.If you link to a page showing the issue I can take a look at it.
Allan
Sorry, didn't notice it before but I suspect the selector in this line is not returning a Datatables API instance:
var table = $("#productlist tr.selected td:nth-last-child(2)").DataTable();
Try changing it to this:
var table = $("#productlist").DataTable();
Kevin