Newbie question
Newbie question
I want to filter Table_2 with the value in the first column of a row selected in Table_1.
What am I doing wrong?
[code]
$("#Table_1 tbody").click(function(event) {
// guessing td is the node and tr is the parent node
var aPos = oTable_1.fnGetPosition( $(event.target.parentNode) );
// get the data array for the row --- don't know why [0] is needed
var aData = oTable_1.fnGetData( aPos[0] );
// hoping this is the first column value and the filter will work but it does not.
oTable_2.fnFilter( aData[0] );
}
})
[/code]
What am I doing wrong?
[code]
$("#Table_1 tbody").click(function(event) {
// guessing td is the node and tr is the parent node
var aPos = oTable_1.fnGetPosition( $(event.target.parentNode) );
// get the data array for the row --- don't know why [0] is needed
var aData = oTable_1.fnGetData( aPos[0] );
// hoping this is the first column value and the filter will work but it does not.
oTable_2.fnFilter( aData[0] );
}
})
[/code]
This discussion has been closed.
Replies
[code]// guessing td is the node and tr is the parent node
var aPos = oTable_1.fnGetPosition( $(event.target.parentNode) );[/code]
fnGetPosition expects a TR or TD, but you are giving it a $(TR) (jQuery object wrapped around TR)
----
also you can skip the middle man and just put the TR directly into fnGetData
[code] $("#Table_1 tbody").click(function(event) {
// get the data array for the row
var aData = oTable_1.fnGetData(event.target.parentNode );
// hoping this is the first column value and the filter will work but it does not.
oTable_2.fnFilter( aData[0] );
}
})
[/code]
------------
You should check to make sure that the event.target is what you are expecting, rather than just assuming.
inspect it with console.log(event.target); and open the debugger.