How to get data array by clicking on a TR?
How to get data array by clicking on a TR?
Hello everyone,
I have many and many independant datatables placed on my HTML page (on a jQuery tabs) and I would like to get the data array of a TR when clicking on every row of every table.
After init, all tables have an ID in this form: mydatatablegroupea1, mydatatablegroupea2, mydatatablegroupea3, mydatatablegroupea4 and so on...
Now, how is the best way to get by click all the values of a particular TR of a particular datatable?
I tried by myself with for example fnGetData(this) but it does not work. :-(
[code]
$("table[id*=mydatatablegroupea] tbody tr").click(function() {
var trArray = $(this); //How to get the TR values here?
alert(trArray);
echo '});
[/code]
Could you please help?
Thanks.
Regards.
I have many and many independant datatables placed on my HTML page (on a jQuery tabs) and I would like to get the data array of a TR when clicking on every row of every table.
After init, all tables have an ID in this form: mydatatablegroupea1, mydatatablegroupea2, mydatatablegroupea3, mydatatablegroupea4 and so on...
Now, how is the best way to get by click all the values of a particular TR of a particular datatable?
I tried by myself with for example fnGetData(this) but it does not work. :-(
[code]
$("table[id*=mydatatablegroupea] tbody tr").click(function() {
var trArray = $(this); //How to get the TR values here?
alert(trArray);
echo '});
[/code]
Could you please help?
Thanks.
Regards.
This discussion has been closed.
Replies
Allan
Thank you for your reply but it does not work in my case. When I try to use the object oTable, I get a JS error "oTable is not defined".
Here is my complete code at now:
[code]
$(function(){
//Init the tabs
$("#tabs").tabs();
//Init all HTML tables placed on the tabs
$("table[id*=mydatatablegroupea]").each(function(){
var idtable = $(this).attr("id");
$("#"+idtable).dataTable({
"bSort": true,
"aaSorting": [],
"bPaginate": false,
"bAutoWidth": false,
});
});
//When clicking on a row of a table, we need to get the TR array values of this specific table
$("table[id*=mydatatablegroupea] tbody tr").click(function() {
var trArray = $(this); //How to get the TR values here?
alert(trArray);
});
});
[/code]
At once, I can have to generate more than 5 independants HTML tables on the DOM.
Any idea?
Thanks.
Regards.
[code]
$(this).parents('table').dataTable()
[/code]
Allan
Thank you very much, Allan.