Proper way to obtain the backing javascript object for a row?

Proper way to obtain the backing javascript object for a row?

rrullorrullo Posts: 4Questions: 0Answers: 0
edited June 2011 in General
Given an element is there a simple way to obtain the backing javascript object for a row? Currently I've added my own getData function to a table to fetch the value, but I feel like I'm in a place I should not be and that there should be an API for what I'm trying to do.

This is the code that is working for me at the moment, but like I said, probably can be better, safer.

{code}
table[ 'getData' ] = function(element) {
var aPos = table.fnGetPosition( element );
var row = aPos[0];

// Not thrilled with what I would consider a private property _aData. Still searching for better solution.
var data = table.dataTable().fnSettings().aoData[row]._aData;

return data;
}
{code}

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    http://datatables.net/api#fnGetData

    [code]
    var data = oTable.fnGetData( element );
    [/code]

    should do it. Or am I missing something? :-)

    Allan
  • rrullorrullo Posts: 4Questions: 0Answers: 0
    Thanks again Allan. That does solve it.
This discussion has been closed.