fnGetData - Using elements to get back row data...
fnGetData - Using elements to get back row data...
talkitivewizard
Posts: 30Questions: 0Answers: 0
I'm trying to get data from a table by clicking a button that is within a cell in that row... So what I thought I would do is pass the TR of that row to fnGetData by using jQuery to grab the parent of the td the button is in. So I have the following:
[code]
...
<?=$class['CLASS_ID']?>
<?=$class['CALL_NUMBER']?>
Remove
...
[/code]
[code]
function removeClass(element)
{
var row = classTable.fnGetData(element);
var id = row[0];
...
}
[/code]
I would think this would work... I've tried variants such as fnGetData(element[0]) since technically jQuery returns an array but I always get this same error. oSettings.aoData[iRow] is undefined. I'm using 1.6.1... Any ideas? all the examples I found so far use "this" passed directly to the fnGetData function where this is the tr element that has been clicked.
[code]
...
<?=$class['CLASS_ID']?>
<?=$class['CALL_NUMBER']?>
Remove
...
[/code]
[code]
function removeClass(element)
{
var row = classTable.fnGetData(element);
var id = row[0];
...
}
[/code]
I would think this would work... I've tried variants such as fnGetData(element[0]) since technically jQuery returns an array but I always get this same error. oSettings.aoData[iRow] is undefined. I'm using 1.6.1... Any ideas? all the examples I found so far use "this" passed directly to the fnGetData function where this is the tr element that has been clicked.
This discussion has been closed.
Replies
Thanks,
Allan
[code]
function removeClass(element)
{
console.log(element[0]);
var row = classTable.fnGetData(element[0]);
console.log(row);
var id = row[0];
console.log(id);
...
}
[/code]
Of course this is what I get back
oSettings.aoData[iRow] is undefined
fnGetData()jquery...bles.js (line 1531)
removeClass()classM...ment.js (line 114)
function onclick(event) { removeClass($($(this).parent(":first")).parent(":first")); }()Allan?...t/seq/4 (line 2)
[Break on this error] return oSettings.aoData[iRow]._aData;
Meaning that It is only getting to the first console.log() showing the TR as I expected to find however I had tried to do this :first and of course it returns the exact same results... seeing as each item
I've tried a few variations such as
$($(this).parent(':first')).parent(':first')
$($(this).parent(':first')).parent(':first')[0]
$('#classManagement tr:eq(1)')[0]
and in those cases I manipulated the "element" variable to where it only returns 1 item... the same "" that has been showing up. I'm at a loss on this one. I'm not quite sure what's going on... I can't even give it a normal TR and it work...
Maybe it's a stupid mistake somewhere else... Here is my full js file http://anatolefaci.com/dev/Allan/js/classManagement.js as it stands and HTML... Unfortunatly I'm going to have to find a plan "B" as with more times than not... I'm under a tight deadline of tonight to get this feature released.
[code]
Class Management
ID
Class
<?foreach(Application::$layout->classes as $class)
{
?>
<?=$class['CLASS_ID']?>
<?=$class['CALL_NUMBER']?>
Remove
<?
}
?>
ID
Class
Use a csv file to upload multiple classes at once. To see a sample csv file. Click here.
Upload Classes:
Upload
[/code]