Use fnGetSelected() to return a value in the selected row

Use fnGetSelected() to return a value in the selected row

azul347azul347 Posts: 1Questions: 0Answers: 0
edited December 2011 in General
Hello, a bit of a newb with DataTables but I hope this is an easy answer. I want to update a tag to display a value of a specific cell in the row I select.

[code]
$(document).ready(function() {
/* 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');
//
var anSelected = fnGetSelected( oTable );
//
var anSelectedData = anSelected.**GET CELL DATA**
//
showPanel(anSelectedData);

});

function showPanel(cellID) {
document.getElementById("testing").innerHTML = cellID;

}
[/code]

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    The fnGetData API method is what you want:

    [code]
    var anSelectedData = oTable.fnGetData( anSelected[0] );
    [/code]

    Allan
This discussion has been closed.