Selected Row Index of a selected row in a Datatable

Selected Row Index of a selected row in a Datatable

austinjacobaustinjacob Posts: 2Questions: 0Answers: 0
edited October 2012 in General
Hi,

I need to get the selected rowindex of a paginated data table. The problem is when I refresh the datatable using ajax. I am getting some random number as selected row index or row number. But for the first time I am getting correct row index.

Currently I am using the following line of code to get the selected row index under fnRowSelected function of tabletools

[code]
var oTable1 = $('#exampleTable').dataTable();
var oSettings1 = oTable1.fnSettings();
var iCurrentPage1 = Math.ceil(oSettings1._iDisplayStart / oSettings1._iDisplayLength) + 1;
selectedRowIndex1=$(node).closest('tr')[0].sectionRowIndex+(iCurrentPage1-1)*oSettings1._iDisplayLength;
[/code]

Kindly let me know a solution for this.

Thanks in Advance...!!!

Replies

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    I'd suggest that you probably don't want a row index since that (as you are seeing) can change. It might be a better idea to assign an id to each row and us that as a unique identifier?

    Allan
  • austinjacobaustinjacob Posts: 2Questions: 0Answers: 0
    Hi Allan,

    Thanks for your response. I am getting Row Id Properly.

    But When the Child Table load repeatedly, I am getting an Object Not Found Error When I select some rows. But this error is not happening, when the child datatable loads for the first time.

    Thanks
    Austin
This discussion has been closed.