Getting value of selected rows
Getting value of selected rows
I've been reading the post but still haven't gotten any of the following to work. Any suggestions are greatly appreciated. When I do this, which on found in forums I get live is not a function.
$("#example tbody tr").live("click", function(event){
var id = myTable.fnGetData(this)[0];
displayUserInfo(UnitIdd);
});
When I did this, it worked until I added the next 2 lines. Then it didn't run the function looks like as soon as I add the tr it doesn't hit the function.
$('#example tbody ').click(function (e) {
alert('test');
});
$('#example tbody tr').click(function (e) {
var id = myTable.fnGetData(this)[0];
displayUserInfo(UnitId);
alert('test');
});
Here is the table setup
<div class="row">
<div class="col-xs-12">
<table style="width:100%;" class="display table-responsive" cellspacing="0" id="example" >
<thead>
<tr>
<th>Unit ID</th>
<th>Unit Type</th>
<th>UnitTypeDesc</th>
<th>SqFtg</th>
<th>Bedrooms</th>
<th>Bathrooms</th>
<th>Market Rent</th>
<th>Floor Plan</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This question has an accepted answers - jump to answer
Answers
this may make a difference my rows are grouped.
Here is table initializecode.
Hello,
hope this helps:
Cheers
Hannes
Thank you for the response and I do get the table but I'm not sure how to get to the individual columns like my unit ID and UniType values
Could you tell me what you get printed into the console?
Cheers
Hannes
Is there a way to get you a picture of it?
Hi,
To get the individual data points you would just access them like you would a normal object - the
row().data()
method will return the original object that was used for the row.For example:
Note that you will also need to change:
var oTable = $('#example').dataTable({
to be (note the capital D):Otherwise you would run into this FAQ.
Regards,
Allan
ok, I have it with the .DataTable, but when I look at the rowData it has a 0: object and if I click that then I see my fields.
I see rowData as an object. Not sure how to get to that data.
Sent email with picture from console.
I changed the code to row instead of rows and that took care of the problem
thank you, love the this plugin!