[SOLVED]fnRowSelected gives me a undefined array
[SOLVED]fnRowSelected gives me a undefined array
Hi all,
I need to be able to read cell from the certain column.
I am using this:
[code]
"fnRowSelected": function ( node ) {
alert( 'The row with ID '+ node[1]+' was selected' );
}
[/code]
But I can't read anything from the node. It is always undefined. how can I access certain column from the node?
I need to be able to read cell from the certain column.
I am using this:
[code]
"fnRowSelected": function ( node ) {
alert( 'The row with ID '+ node[1]+' was selected' );
}
[/code]
But I can't read anything from the node. It is always undefined. how can I access certain column from the node?
This discussion has been closed.
Replies
> 1. node : TR element which was selected
So I don't understand what `node[1]` is meant to be since its not an array? `node.id` would give you the id...
Allan
So that's why I tried to experiment with bunch of different approaches but non of that is working and I am always getting [code]undefined[/code] value.
So any idea?
Have you attached `Latitude` to the node?? Or is `Latitude` in the data source object for the row? I think you want `table.fnGetData(node).Latitude` .
Allan
[code]alert( 'The row with Latitude '+ table.fnGetData(node).Latitude +' was selected' );[/code]
So I tried with defining datatable like [code]var oTable=...[/code] and still the same thing.
So when you wrote "table" I need to write what?
No - use your DataTables instance...
If that doesn't work please link us to a page showing the problem.
Allan
But at least I can give you more information, so this is how it all looks like:
[code]
var oTable = $('#stops').dataTable( {
"sDom": 'T,lfrtip',
"oTableTools": {
"sSwfPath": "../swf/copy_csv_xls_pdf.swf",
"sRowSelect": "single",
"fnRowSelected": function ( node ) {
alert( 'The row with Latitude '+ oTable.fnGetData(node).Latitude +' was selected' );
}
},
"bProcessing": true,
"bServerSide": true,
"aoColumnDefs": [
{ "bVisible": false, "aTargets": [ 7 , 8] }
],
"sPaginationType": "full_numbers",
"bSort": false,
"bDeferRender": true,
"sAjaxSource": new_url ,
"bDestroy": true,
} )
;
[/code]
And error that I'm getting is this:
[code]
Uncaught TypeError: Cannot call method 'toLowerCase' of undefined
[/code]
at [code] jquery.dataTables.js:5522 [/code]
http://jsfiddle.net
Are both available to recreate an example test case so wee can discover exactly what is going on.
http://live.datatables.net/isahip/4/edit
Do I at least have everything that I need?
http://live.datatables.net/isahip/5/edit
Now it has a column count issue - which is correct, the HTML has 5 columns, your aoColumns uses 9 columns.
Can you be more specific with
[quote]allan said: The script loading order was incorrect[/quote]
What do you mean?
1. DataTables
2. TableTools
3. jQuery
Which version did you save it to?
This is my last change
http://live.datatables.net/isahip/7/edit
I really don't understand you with that load order.
So annoyingly it appears the TableTools documentation is slightly wrong - it is passing an array :-(. That might have been a recent change. I'll need too look into it. Sorry about that.
Here is a working test case: http://live.datatables.net/isahip/8/edit
Allan