unable to get position and data when more than one datatable on the page

unable to get position and data when more than one datatable on the page

satrn_grlsatrn_grl Posts: 4Questions: 0Answers: 0
edited September 2013 in General
I have a dynamic number of datatables on the page. If only one datatable is showing, I'm able to get the position and data using fnGetPosition and fnGetData. However, if there is more than one table on the page, I'm getting the position and data from the last table on the page only.

I think this problem has something to do with the way I'm assigning oTable. How should I do this so that I can properly identify the tables?

[code]
$(document).ready(
function() {
...other stuff

var oTable;
$('.myTable').each(function() {
var tid = $(this).attr('id');
//alert(tid);
oTable= $(this).dataTable({
bFilter: false,
sPaginationType: 'full_numbers',
bSort: true,
bJQueryUI: true,
fnDrawCallback: function(oSettings) {

},
aoColumns: [
null,
null,
null,
null,
null,
null,
null,
null,
null,
{
data: " {'E':'Letter E','F':'Letter F','G':'Letter G', 'selected':'F'}",
type: 'select',
submit: 'ok'
}
]
});
});

$('[id^="reason"]').on('change',
function(){
var aPos = oTable.fnGetPosition(this);
var selrow = oTable.fnGetData(aPos[0]);
var valu = $(this).find('select#reason').val();
alert(selrow); //THIS IS THE DATA FROM THE LAST TABLE
}
);
[/code]

Replies

  • satrn_grlsatrn_grl Posts: 4Questions: 0Answers: 0
    i figured this out. i needed to create an array of objects, assign each table to an object and push the object onto the array.
This discussion has been closed.