How to access data
How to access data
rpmccormick
Posts: 136Questions: 18Answers: 0
Hi Allan. I was hoping you could tell me how to do this correctly... I just need to access all data within a row ID. I had a button on the table, but since I need visible variables to capture I decided to move the button to the details (using responsive plugin). Here is the buttons code that cross-posts to a separate tables New button...
//var
// Handler for button click
$("#Reservations tbody").on('click', 'input', function (e)
{ //var id = $(this).parents('tr').attr('id').substring(4, 13);
var id = $(this).parents('tr').prev().attr('id').substring(4, 13);
var $rootRow = $(this).parents('tr').prev().find('td');
var $detailRow = $(this).parents('ul').find('li > span.dtr-data');
//var resDataTable = $('#Reservations').DataTable();
//var tableData = resDataTable.data(); // or .columns.data?
$('#ResID').val(id);
fareedit.create({title: 'Create Fare and Assign Affiliate', buttons: 'Create and E-Mail Affiliate'});
fareedit.field('FareID').set(id);
fareedit.field('ResID').set(id);
fareedit.field('FarePickupTime').set($detailRow[7].innerText);
.......many fields.......
fareedit.field('DriverID').set($rootRow[3].innerText);
fareedit.field('VehicleID').set($rootRow[4].innerText);
} );
I'd love to get rid of all the data-passing fields.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Bump :( Can someone please post an example of $('#Reservations').Data() retrieving column values for the selected row? ...from within the onclick of a button I added to the row.
Hi,
It says just below the message input box :-). Also in the Markdown guide.
Regarding your question: Use the
responsive.index()
method to get the row index for the selected row, then you can userow().data()
to get the data for the row:Allan
Awesome, thanks!