How to find precedent aData ?

How to find precedent aData ?

pearly_030pearly_030 Posts: 42Questions: 0Answers: 0
edited August 2011 in General
Hi,

Is it possible to compare the actual line's aData with precedents line's aData ?

i'll try to be a bit clearer :
My code :
[code]
$.fn.dataTableExt.afnFiltering.push(
//oTable.dataTableExt.afnFiltering.push(

function( oSettings, aData, iDataIndex ) {
var iDebut = aData[3];
......
[/code]
Here I want to compare iDebut with iData[3] of the precedent line of the datatable.

Is it possible ? I don't find.

Thanks

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    It is possible, you you need to be aware of how DataTables works internally... :-)

    iDataIndex tells you what row in the internal data store you are working with - the data store is available in oSettings.aoData (i.e. oSettings.aoData[ iDataIndex ]._aData == aData in this case). So the preceding data set in the order that it was originally read in is oSettings.aoData[ iDataIndex-1 ]._aData.

    The thing to watch here is that the internal data store index might not be the same as the display index (due to sorting)! So what you need to do is look up where iDataIndex is in the aiDisplay array (oSettings.aiDisplay) and then take one away from that index to get the display order. A little complicated I'm afraid, but certainly possible :-)

    Allan
  • pearly_030pearly_030 Posts: 42Questions: 0Answers: 0
    Thanks for your response.
    I understood that iDataIndex was the solution's key and then I stored data in a new array.
    I didn't understand the oSettings.aoData array but now, with your explication, it will be better.

    Thanks.
This discussion has been closed.