Using fnGetAdjacentTr Plug-In when clicking a DataTables row
Using fnGetAdjacentTr Plug-In when clicking a DataTables row
torvictech
Posts: 3Questions: 0Answers: 0
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
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
This discussion has been closed.
Replies
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
When I use the code as you suggested, instead of a "null" for nNext I get "[object HTMLTableRowElement]".
Thanks for your help.
Vic
Thanks,
Vic
Allan