I want to get the value of the invisible cell next to the one that the user selects
I want to get the value of the invisible cell next to the one that the user selects
MarkAinsworth
Posts: 6Questions: 3Answers: 1
My code looks like this:
$(document).ready(function () {
$('#vendorList').DataTable({
select: {
style: 'os',
items: 'cell'
},
ajax: {
url: "vendors.php",
dataSrc: ""
},
columns: [
{data: "catalogManufacturer"},
{data: "VendorNumber",
visible: false}
]
});
//when vendor is selected, show items
var vTable = $('#vendorList').DataTable();
vTable.on( 'select', function (e, dt, type, indexes) {
var idx = vTable.cell('.selected').index();
var rowData = vTable.rows(idx.row).columns(idx.column).data();
console.log(rowData);
});
});
The table is populated as expected. My json is just an array of associated arrays.
rowData appears to be the entire column at this point.
How do i get just the value for the colum
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Basically
rowData
containscolumns(idx.column).data()
which will be all the data in that column. Usingrow()
won't filter the data returned usingcolumn()
even if chained like you have.Use
cell().data()
. Maybe something like this:Kevin
Simple enough. Thanks, Kevin for taking the time to answer.