Access cell data from selected row
Access cell data from selected row
bbrindza
Posts: 316Questions: 73Answers: 1
I could use a little insight on .rows('.selected').data(). I need to access cell data from a selected row but I can not even get past to accessing the TR data. My following scripts returns [object Object] in my alert, when I should see the data in the selected rows. I exhausted all my resources trying to solve this. Any help would be greatly appreciated .
var mfgTable;
$(document).ready( function () {
mfgTable = $( "#ManufacturerTable" ).DataTable({
ordering: false,
iDisplayLength: 20,
oLanguage: {sSearch: "Table Search: "},
processing: true,
serverSide: true,
ajax: {url: "ssp_getManufacturersData.php",}
},
columns: [
{ orderable: false,
className: 'select-checkbox',
targets: 0,
data: null,
defaultContent: '',
width: '10px',
},
{ data: "vendor_number"},
{ data: "manufacturer_name" },
{ data: "manufacturer_address"},
{ data: "manufacturer_city" },
{ data: "manufacturer_state" },
{ data: "manufacturer_zipcode" },
{ data: "manufacturer_type" },
{ data: "manufacturer_status" },
],
select: {
style: 'os',
selector: 'td:first-child'
},
});
} );
// Function called from button after row is checked
function getTableRowData( ){
var tableData = mfgTable.rows('.selected').data();
var tempData;
$.each(tableData , function(i, val) {
tempData= tableData [i];
alert(tempData);
});
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
This returns an array objects. The
tempData
variable will contain one row of data objects. If you change youralert
toconsole.log
you will see this. Or you could do something like this to see one value:Kevin
Thank you Kevin.. That seemed simple.