Individual detail text for each row

Individual detail text for each row

joejames800joejames800 Posts: 6Questions: 0Answers: 0
edited November 2011 in General
I found this code below on http://datatables.net/release-datatables/examples/api/row_details.html

But when I make a change it applies it to all the row details... How do you change the row details to have individual detail text for each row? Could someone please provide an example?

[code]/* Formating function for row details */
function fnFormatDetails ( oTable, nTr )
{
var aData = oTable.fnGetData( nTr );
var sOut = '';
sOut += 'Rendering engine:'+aData[1]+' '+aData[4]+'';
sOut += 'Link to source:Could provide a link here';
sOut += 'Extra info:And any further details here (images etc)';
sOut += '';

return sOut;
}
[/code]

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    The part with "aData[1]+' '+aData[4]" is the part which renders based on the information in the individual row. If you want something custom to each row, you would need to do some conditional matching to figure out what row you are looking at and then inject the required HTML.

    Allan
  • joejames800joejames800 Posts: 6Questions: 0Answers: 0
    Is there an example of this somewhere? Sorry I'm a beginner... I don't the first step in conditional matching?
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    Not really - you've already posted the code from the example :-)

    Do you understand what aData is in the context of that function? It might help if you 'console.log(aData)' and have a look at the Firebug console to see what aData is (its the data fromt he row that is being "opened".

    Allan
This discussion has been closed.