Using fnGetAdjacentTr Plug-In when clicking a DataTables row

Using fnGetAdjacentTr Plug-In when clicking a DataTables row

torvictechtorvictech Posts: 3Questions: 0Answers: 0
edited July 2012 in General
Hello - I have configured the fnGetAdjacentTr plug-in as per the general setup and now am ready to use it, but am faced with some issues.

Here is my code:
[code]
var tblIndex;
$('#tblWOs tbody td').live('click', function () {
var tblClickPos = $('#tblWOs').dataTable().fnGetPosition(this);
tblIndex = tblClickPos[0];

var tblWorkOrderData = $('#tblWOs').dataTable().fnGetData(tblIndex);
var n1 = tblWorkOrderData;
var nNext = $('#tblWOs').dataTable().fnGetAdjacentTr(n1);
var nPrev = $('#tblWOs').dataTable().fnGetAdjacentTr(n1, false);
alert(n1);
alert(nNext);
alert(nPrev);

loadWorkOrderDetails();
checkWODpaging();
});
[/code]

Here are the results of the three alerts:
alert(n1) = "show the data for the clicked row, eg. 1, text, text, number, etc..."
alert(nNext) = "null"
alert(nPrev) = "null"

Your help is much appreciated.

Thanks,
Vic

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    Hi Vic,

    fnGetAdjacentTr takes a node, not data as the first parameter. So I would suggest you just want to use:

    [code]
    nNext = $('#tblWOs').dataTable().fnGetAdjacentTr( this.parentNode );
    [/code]

    Allan
  • torvictechtorvictech Posts: 3Questions: 0Answers: 0
    Hi Allan,

    When I use the code as you suggested, instead of a "null" for nNext I get "[object HTMLTableRowElement]".

    Thanks for your help.
    Vic
  • torvictechtorvictech Posts: 3Questions: 0Answers: 0
    Could you please help me understand what this functin is supposed to return?
    Thanks,
    Vic
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    A TR node, which is exactly what it sounds like it is doing if your are getting a table row element. What did you expect it to do?

    Allan
This discussion has been closed.