datatables with fixedheader: row click function giving error on fixed cols -


i have on click function storing row data in console log

if click on first 2 columns, you'll notice function returns undefined, of unfrozen columns returns data object

i know has todo fact fixedcolumns created in cloned table, wondering if there workaround this?

// server-side processing object sourced data var $table; $(document).ready(function() {     $table = $('#example').datatable( {         "processing": true,         "serverside": true,         "ajax": "/ssp/objects.php",       dom: "<'row'<'col-md-6 'l><'col-md-6 pull-right'>r>t<'row'<'col-md-6'i><'col-md-6'p>>",         "columns": [             { "data": "first_name" },             { "data": "last_name" },             { "data": "position" },             { "data": "office" },             { "data": "start_date" },             { "data": "salary" }         ],      scrolly: "600px",     scrollx: "100%",     scrollcollapse: true,         "pagelength": 5,   lengthmenu: [[5, 10, 25, 50 ], [5, 10, 25, 50]],   order: [[ 1, "asc" ]],     } );      new $.fn.datatable.fixedcolumns( $table, {         leftcolumns: 2     } );     $table.on("click", "tr",function(){   var adata = $table.row( ).data();   console.log( adata);   } );   } ); 

here example code in action

you can use fngetposition information row index.

from manual:

this function functionally identical fngetposition in datatables, taking same parameter (th, td or tr node) , returning the same information (data index information). difference between 2 method takes account fixed columns in table, can pass in nodes master table, or cloned tables , index position data in main table.

your code needs modified follows:

var fc = new $.fn.datatable.fixedcolumns( $table, {    leftcolumns: 2 });    $table.on("click", "tr", function(){    var adata = $table.row(fc.fngetposition(this)).data();    console.log(adata); }); 

see example code demonstration.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -