[Help] Select a row after fnAddData

[Help] Select a row after fnAddData

shihyishihyi Posts: 3Questions: 0Answers: 0
edited July 2011 in General
Dear All,

I have another problem about insert and select a row.
I insert table dynamic use fnAddData.
Insert function is find.
But after insert, I want select a row, and I use fnGetData.
Then I can't select a row I insert before.

Javascript as following.
[code]
$('#example tbody tr').click( function () {
var aData = $('#example').dataTable().fnGetData( this );
alert(aData[0]);
alert(aDate[1]);
});
[/code]

HTML as following.
[code]



Head_1
Head_2




1
2



[/code]

I just can't select row use fnGetData.
if I write a table use HTML, I can select any row I want.
Any one can help?


Best Regards,
Shihyi Chiu

Replies

  • jpsantosjpsantos Posts: 1Questions: 0Answers: 0
    I'm having the same problem. I´m using:
    - jquery.dataTables.js (1.9.0)
    - jquery-1.7.2.min.js

    Any solution?

    Many Thanks!
    João Santos
  • shuarganshuargan Posts: 1Questions: 0Answers: 0
    you have to do something like these
    /* Add a click handler to the rows - this could be used as a callback */
    $("#example tbody").click(function(event) {
    $(oTable.fnSettings().aoData).each(function (){
    $(this.nTr).removeClass('row_selected');
    });
    $(event.target.parentNode).addClass('row_selected');
    });

    (extracted from http://datatables.net/examples/api/select_single_row.html)
This discussion has been closed.