DataTables Editor with previous / next buttons + fnFilter

DataTables Editor with previous / next buttons + fnFilter

SevSev Posts: 3Questions: 0Answers: 0
edited April 2013 in Editor
I would like to use Previous/Next buttons on the Editor but I also use fnFilter to limit the number of rows to display.
Unfortunately, with the Previous/Next I jump to the next in the database without any consideration to the fnFilter.
Could you tell me if I have to add this fnFilter somewhere else in aButtons or if this is just a bug ?
http://editor.datatables.net/release/DataTables/extras/Editor/examples/back-next.html

Thanks
Sev

Replies

  • allanallan Posts: 63,494Questions: 1Answers: 10,470 Site admin
    Hi Sev,

    This is the key piece of code:

    > table.$('tr')[index+1]

    That uses the `$` method ( http://datatables.net/docs/DataTables/1.9.4/DataTable.html#$ ) to get the next row. As you'll be able to see from the documentation, by default `$` does not take into account filtering, but you can easily make it do so:

    [code]
    table.$('tr', {filter:'applied'})[index+1]
    [/code]

    Likewise for the 'previous' button and that should do it.

    Regards,
    Allan
  • SevSev Posts: 3Questions: 0Answers: 0
    edited April 2013
    Thanks, I changed 2 lines on next and previous and it worked well :
    [code] var index = table.$('tr', {"filter": "applied"}).index(row);[/code]
    and
    [code] tt.fnSelect( table.$('tr', {"filter": "applied"})[index-1] );[/code]
This discussion has been closed.