how to add uniq id to row
how to add uniq id to row
I have data returned in json format from server side. Problem is once row selected how to get data for this row.
Examples in documentation says to traverse in the row, which is useless because i don't display all data in each row.
There is a method fnGetData which return aoData (full set of data), but data identified by "id" property. That means, I have to keep somewhere in row information about id and tuple shown in the row.
I did try to hide it in span element in first column but it break visual style when column selected since first parent not a tr element any more.
I did try to use hide column with id inside which is as well did not work. It break table, or show error message that no data for column 0, or just ignore/remove column from table with id. (i really i cant understand why datatables removes column which is marked as "bVisible" :false if i can just do not include it in column definition and it will behave same)
Any ideas??
Only solution i found for now is to add fake node into each cell so cell value will be wrapped in span element, and when row is selected use second parentNode to get into row element.
Examples in documentation says to traverse in the row, which is useless because i don't display all data in each row.
There is a method fnGetData which return aoData (full set of data), but data identified by "id" property. That means, I have to keep somewhere in row information about id and tuple shown in the row.
I did try to hide it in span element in first column but it break visual style when column selected since first parent not a tr element any more.
I did try to use hide column with id inside which is as well did not work. It break table, or show error message that no data for column 0, or just ignore/remove column from table with id. (i really i cant understand why datatables removes column which is marked as "bVisible" :false if i can just do not include it in column definition and it will behave same)
Any ideas??
Only solution i found for now is to add fake node into each cell so cell value will be wrapped in span element, and when row is selected use second parentNode to get into row element.
This discussion has been closed.
Replies
There are lots of ways :-). How is the row selected? If by a class name then you could do:
[code]
var data = table._( 'tr.selected' );
[/code]
which will put an the data for the selected rows into the variable `data` .
> There is a method fnGetData which return aoData (full set of data)
You can also pass in a node - `table.fnGetData( $('#myRow')[0] );` .
Better yet is the new API in DataTables 1.10 you very simply do: `table.row( '#myRow' ).data();` . No mucking around. 1.10 should go into beta today.
> i really i cant understand why datatables removes column which is marked as "bVisible" :false
Because setting them to `display: none` causes cross browser display problems. Most browsers work okay with it, but not all (the older ones mainly). Thus, DataTables removes the elements from the DOM.
Can you
Allan