How to access data Object

How to access data Object

AkhorAkhor Posts: 6Questions: 0Answers: 0
edited December 2012 in DataTables 1.9
Hi,

How can I access the columns full mData when a table is setup like below:


var columns = [ { mData: dynamic.title } ];
var data = [ { dynamic: {title:'Test', desc: 'description', value3: 'val3' } } ];


$('#table').dataTable( {aaData: data, aoColumns: columns, fnCreatedCell: function(nTD,sData,oData,iRow,iCol){
alert( sData ); //Shows "Test"

//How can I get the whole object?
// { dynamic: {title:'test', desc: 'description', value3: 'val3' }


} });

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    To get the data for the whole column, you currently need to use a plug-in: http://datatables.net/plug-ins/api#fnGetColumnData

    Allan
  • AkhorAkhor Posts: 6Questions: 0Answers: 0
    Oh thanks! I found I can also use mRender and return the data according to the "type"

    mRender: function (data, type,val){
    if (type === 'display'){
    return data;
    }else if (type === 'filter'){
    return data.display;
    }
    return data;
    } };
This discussion has been closed.